From fd5154f16450659c7c6f30c7785932349c8f1235 Mon Sep 17 00:00:00 2001 From: Kavish Devar Date: Sat, 28 Sep 2024 12:30:29 +0530 Subject: [PATCH] organize examples --- README.md | 42 +++++++++++++------ .../daemon/ear-detection.py | 0 .../daemon/read-data.py | 0 .../daemon/set-anc.py | 0 4 files changed, 29 insertions(+), 13 deletions(-) rename experimental_pause-play.py => examples/daemon/ear-detection.py (100%) rename example_deamon_read.py => examples/daemon/read-data.py (100%) rename example_deamon_send.py => examples/daemon/set-anc.py (100%) diff --git a/README.md b/README.md index 83ec425..f948969 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ ![Main Demo (Screenshot 2024-09-27 at 3 06 56 AM)](https://github.com/user-attachments/assets/352275c8-e143-42c3-a06a-fc3ac0c937b9) # Get Started! + ## 1. Install the required packages ```bash @@ -28,32 +29,40 @@ Pair your AirPods with your machine before running this script! :warning: **Note:** DO NOT FORGET TO EDIT THE `AIRPODS_MAC` VARIABLE IN `main.py`/`standalone.py` WITH YOUR AIRPODS MAC ADDRESS! ## 4. Run! -You can either choose the more polished version of the script, which currently only supports fetching the battery percentage, and in-ear status (but not actually controlling the media with that information), or the more experimental standalone version of the script, which supports the following features: -- Controlling the media with the in-ear status -- Remove the device as an audio sink when the AirPods are not in your ears. -- Try to connect with the AirPods if media is playing and the AirPods are not connected. +You can either choose the more polished version of the script, which currently only supports +- fetching the battery percentage, +- and in-ear status (but not actually controlling the media with that information) +or the more experimental versions of the script (features listed in respective sections). -### Polished version +# Versions +## Polished version ```bash python3 main.py ``` -### Experimental version +## Experimental versions + +### Standalone version (without module dependency) +- Controlling the media with the in-ear status +- Remove the device as an audio sink when the AirPods are not in your ears. +- Try to connect with the AirPods if media is playing and the AirPods are not connected. ```bash python3 standalone.py ``` -## Daemonizing -If you want to run this as a deamon, you can use the `airpods_daemon.py` script. This creates a standard UNIX socket at `/tmp/airpods_daemon.sock` and listens for commands (and sends battery/in-ear info, soon!). - +### Daemonizing +If you want to run a deamon for multiple programs to read/write airpods data, you can use the `airpods_daemon.py` script. +- This creates a standard UNIX socket at `/tmp/airpods_daemon.sock` and listens for commands +- and sends battery/in-ear info You can run it as follows: ```bash python3 airpods_daemon.py ``` +#### Scripts to interact with the daemon -### Sending data to the daemon -You can send data to the daemon using the `send_data.py` script. Since it's a standard UNIX socket, you can send data to it using any programming language that supports UNIX sockets. +- Sending data to the daemon +You can send data to the daemon using the `example_daemon_send.py` script. Since it's a standard UNIX socket, you can send data to it using any programming language that supports UNIX sockets. This package includes a demo script that sends a command to turn off the ANC. You can run it as follows: @@ -61,9 +70,16 @@ This package includes a demo script that sends a command to turn off the ANC. Yo python3 example_daemon_send.py ``` -### Reading data from the daemon -Youhcan listen to the daemon's output by running the `example_daemon_read.py` script. This script listens to the UNIX socket and prints the data it receives. Currenty, it only prints the battery percentage and the in-ear status. +- Reading data from the daemon +You can listen to the daemon's output by running the `example_daemon_read.py` script. This script listens to the UNIX socket and prints the data it receives. Currenty, it only prints the battery percentage and the in-ear status. ```bash python3 example_daemon_read.py +``` + +- Controlling the media with the in-ear status (and get battery status) +This script is basically the standalone script, but interacts with the UNIX socket created by the daemon instead. It can control the media with the in-ear status and remove the device as an audio sink when the AirPods are not in your ears. + +```bash +python3 ear-detection.py ``` \ No newline at end of file diff --git a/experimental_pause-play.py b/examples/daemon/ear-detection.py similarity index 100% rename from experimental_pause-play.py rename to examples/daemon/ear-detection.py diff --git a/example_deamon_read.py b/examples/daemon/read-data.py similarity index 100% rename from example_deamon_read.py rename to examples/daemon/read-data.py diff --git a/example_deamon_send.py b/examples/daemon/set-anc.py similarity index 100% rename from example_deamon_send.py rename to examples/daemon/set-anc.py