From 1163854907676c58c3a9ebd7747e6e3f0b660a88 Mon Sep 17 00:00:00 2001 From: Kavish Devar Date: Mon, 7 Oct 2024 21:40:11 +0530 Subject: [PATCH] move everything to linux folder --- LICENSE => linux/LICENSE | 0 linux/README.md | 101 ++++++++++++++++++ {aln => linux/aln}/AirPods/Pro2.py | 0 {aln => linux/aln}/AirPods/__init__.py | 0 {aln => linux/aln}/Capabilites/__init__.py | 0 {aln => linux/aln}/Notifications/ANC.py | 0 {aln => linux/aln}/Notifications/Battery.py | 0 .../Notifications/ConversationalAwareness.py | 0 .../aln}/Notifications/EarDetection.py | 0 {aln => linux/aln}/Notifications/Listener.py | 0 {aln => linux/aln}/Notifications/__init__.py | 0 {aln => linux/aln}/__init__.py | 0 {aln => linux/aln}/enums.py | 0 .../examples}/daemon/ear-detection.py | 0 .../examples}/daemon/read-data.py | 0 .../examples}/daemon/set-anc.py | 0 {examples => linux/examples}/daemon/start.py | 0 {examples => linux/examples}/daemon/tray.py | 0 .../examples}/logger-and-anc.py | 0 {examples => linux/examples}/standalone.py | 0 icon.png => linux/icon.png | Bin {imgs => linux/imgs}/daemon-log.png | Bin {imgs => linux/imgs}/ear-detection.png | Bin {imgs => linux/imgs}/read-data.png | Bin {imgs => linux/imgs}/set-anc.png | Bin {imgs => linux/imgs}/tray-icon-hover.png | Bin {imgs => linux/imgs}/tray-icon-menu.png | Bin pyproject.toml => linux/pyproject.toml | 0 start-daemon.py => linux/start-daemon.py | 0 test-head.py => linux/test-head.py | 0 30 files changed, 101 insertions(+) rename LICENSE => linux/LICENSE (100%) create mode 100644 linux/README.md rename {aln => linux/aln}/AirPods/Pro2.py (100%) rename {aln => linux/aln}/AirPods/__init__.py (100%) rename {aln => linux/aln}/Capabilites/__init__.py (100%) rename {aln => linux/aln}/Notifications/ANC.py (100%) rename {aln => linux/aln}/Notifications/Battery.py (100%) rename {aln => linux/aln}/Notifications/ConversationalAwareness.py (100%) rename {aln => linux/aln}/Notifications/EarDetection.py (100%) rename {aln => linux/aln}/Notifications/Listener.py (100%) rename {aln => linux/aln}/Notifications/__init__.py (100%) rename {aln => linux/aln}/__init__.py (100%) rename {aln => linux/aln}/enums.py (100%) rename {examples => linux/examples}/daemon/ear-detection.py (100%) rename {examples => linux/examples}/daemon/read-data.py (100%) rename {examples => linux/examples}/daemon/set-anc.py (100%) rename {examples => linux/examples}/daemon/start.py (100%) rename {examples => linux/examples}/daemon/tray.py (100%) rename {examples => linux/examples}/logger-and-anc.py (100%) rename {examples => linux/examples}/standalone.py (100%) rename icon.png => linux/icon.png (100%) rename {imgs => linux/imgs}/daemon-log.png (100%) rename {imgs => linux/imgs}/ear-detection.png (100%) rename {imgs => linux/imgs}/read-data.png (100%) rename {imgs => linux/imgs}/set-anc.png (100%) rename {imgs => linux/imgs}/tray-icon-hover.png (100%) rename {imgs => linux/imgs}/tray-icon-menu.png (100%) rename pyproject.toml => linux/pyproject.toml (100%) rename start-daemon.py => linux/start-daemon.py (100%) rename test-head.py => linux/test-head.py (100%) diff --git a/LICENSE b/linux/LICENSE similarity index 100% rename from LICENSE rename to linux/LICENSE diff --git a/linux/README.md b/linux/README.md new file mode 100644 index 0000000..987f974 --- /dev/null +++ b/linux/README.md @@ -0,0 +1,101 @@ +# ALN - AirPods like Normal (Linux Only) + +### Check out the packet definitions at [AAP Definitions](/AAP%20Definitions.md) + +## Currently supported device(s) +- AirPods Pro 2 + +### 1. Install the required packages + +```bash +sudo apt install python3 python3-pip +pip3 install pybluez +``` + +If you want to run it as a daemon (Refer to the [Daemon Version](#as-a-daemon-using-a-unix-socket) section), you will need to install the `python-daemon` package. + +```bash +pip3 install python-daemon +``` + +### 2. Clone the repository + +```bash +git clone https://github.com/kavishdevar/aln.git +cd aln +``` + +### 3. Preprare +Pair your AirPods with your machine before running this script! +> **Note:** DO NOT FORGET TO EDIT THE `AIRPODS_MAC` VARIABLE IN EXAMPLE SCRIPTS WITH YOUR AIRPODS MAC ADDRESS BEFORE RUNNING THEM! + +# Versions + +## Non-Daemon based +This version is the most polished version of the script. It can do the following: +- fetch the battery percentage, +- fetch in-ear status (but not actually controlling the media with that information). +- control ANC modes +```bash +python3 examples/logger-and-anc.py +``` + +## As a daemon (using a UNIX socket) +![Daemon Log Screenshot](imgs/daemon-log.png) +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 +``` + +## Interacting with the daemon +![Set ANC Screenshot](imgs/set-anc.png) +- Sending data to the daemon +You can send data to the daemon using the `set-anc.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: + +```bash +python3 examples/daemon/set-anc.py +``` + +- Reading data from the daemon +![Read Data Screenshot](imgs/read-data.png) +You can listen to the daemon's output by running the `read-data.py` script. This script listens to the UNIX socket and prints the data it receives. Currenty, it recognizes the battery percentage and the in-ear status and dumps the rest of the data to the terminal. + +```bash +python3 examples/daemon/read-data.py +``` + +- Controlling the media with the in-ear status (and get battery status) + +![Ear Detection Screenshot](imgs/ear-detection.png) +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 examples/daemon/ear-detection.py +``` + +- App Indicator/Tray Icon + +![Tray Icon Hover Screenshot](imgs/tray-icon-hover.png) +![Tray Icon Menu Screenshot](imgs/tray-icon-menu.png) +This script is a simple tray icon that shows the battery percentage and set ANC modes. It can also control the media with the in-ear status. +> Note: This script uses QT. + +```bash +python3 examples/daemon/tray.py +``` + +## Standalone version (without module dependency, mainly for testing, and reverse engineering purposes) +- 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. +- Control ANC modes. + +```bash +python3 examples/standalone.py +``` diff --git a/aln/AirPods/Pro2.py b/linux/aln/AirPods/Pro2.py similarity index 100% rename from aln/AirPods/Pro2.py rename to linux/aln/AirPods/Pro2.py diff --git a/aln/AirPods/__init__.py b/linux/aln/AirPods/__init__.py similarity index 100% rename from aln/AirPods/__init__.py rename to linux/aln/AirPods/__init__.py diff --git a/aln/Capabilites/__init__.py b/linux/aln/Capabilites/__init__.py similarity index 100% rename from aln/Capabilites/__init__.py rename to linux/aln/Capabilites/__init__.py diff --git a/aln/Notifications/ANC.py b/linux/aln/Notifications/ANC.py similarity index 100% rename from aln/Notifications/ANC.py rename to linux/aln/Notifications/ANC.py diff --git a/aln/Notifications/Battery.py b/linux/aln/Notifications/Battery.py similarity index 100% rename from aln/Notifications/Battery.py rename to linux/aln/Notifications/Battery.py diff --git a/aln/Notifications/ConversationalAwareness.py b/linux/aln/Notifications/ConversationalAwareness.py similarity index 100% rename from aln/Notifications/ConversationalAwareness.py rename to linux/aln/Notifications/ConversationalAwareness.py diff --git a/aln/Notifications/EarDetection.py b/linux/aln/Notifications/EarDetection.py similarity index 100% rename from aln/Notifications/EarDetection.py rename to linux/aln/Notifications/EarDetection.py diff --git a/aln/Notifications/Listener.py b/linux/aln/Notifications/Listener.py similarity index 100% rename from aln/Notifications/Listener.py rename to linux/aln/Notifications/Listener.py diff --git a/aln/Notifications/__init__.py b/linux/aln/Notifications/__init__.py similarity index 100% rename from aln/Notifications/__init__.py rename to linux/aln/Notifications/__init__.py diff --git a/aln/__init__.py b/linux/aln/__init__.py similarity index 100% rename from aln/__init__.py rename to linux/aln/__init__.py diff --git a/aln/enums.py b/linux/aln/enums.py similarity index 100% rename from aln/enums.py rename to linux/aln/enums.py diff --git a/examples/daemon/ear-detection.py b/linux/examples/daemon/ear-detection.py similarity index 100% rename from examples/daemon/ear-detection.py rename to linux/examples/daemon/ear-detection.py diff --git a/examples/daemon/read-data.py b/linux/examples/daemon/read-data.py similarity index 100% rename from examples/daemon/read-data.py rename to linux/examples/daemon/read-data.py diff --git a/examples/daemon/set-anc.py b/linux/examples/daemon/set-anc.py similarity index 100% rename from examples/daemon/set-anc.py rename to linux/examples/daemon/set-anc.py diff --git a/examples/daemon/start.py b/linux/examples/daemon/start.py similarity index 100% rename from examples/daemon/start.py rename to linux/examples/daemon/start.py diff --git a/examples/daemon/tray.py b/linux/examples/daemon/tray.py similarity index 100% rename from examples/daemon/tray.py rename to linux/examples/daemon/tray.py diff --git a/examples/logger-and-anc.py b/linux/examples/logger-and-anc.py similarity index 100% rename from examples/logger-and-anc.py rename to linux/examples/logger-and-anc.py diff --git a/examples/standalone.py b/linux/examples/standalone.py similarity index 100% rename from examples/standalone.py rename to linux/examples/standalone.py diff --git a/icon.png b/linux/icon.png similarity index 100% rename from icon.png rename to linux/icon.png diff --git a/imgs/daemon-log.png b/linux/imgs/daemon-log.png similarity index 100% rename from imgs/daemon-log.png rename to linux/imgs/daemon-log.png diff --git a/imgs/ear-detection.png b/linux/imgs/ear-detection.png similarity index 100% rename from imgs/ear-detection.png rename to linux/imgs/ear-detection.png diff --git a/imgs/read-data.png b/linux/imgs/read-data.png similarity index 100% rename from imgs/read-data.png rename to linux/imgs/read-data.png diff --git a/imgs/set-anc.png b/linux/imgs/set-anc.png similarity index 100% rename from imgs/set-anc.png rename to linux/imgs/set-anc.png diff --git a/imgs/tray-icon-hover.png b/linux/imgs/tray-icon-hover.png similarity index 100% rename from imgs/tray-icon-hover.png rename to linux/imgs/tray-icon-hover.png diff --git a/imgs/tray-icon-menu.png b/linux/imgs/tray-icon-menu.png similarity index 100% rename from imgs/tray-icon-menu.png rename to linux/imgs/tray-icon-menu.png diff --git a/pyproject.toml b/linux/pyproject.toml similarity index 100% rename from pyproject.toml rename to linux/pyproject.toml diff --git a/start-daemon.py b/linux/start-daemon.py similarity index 100% rename from start-daemon.py rename to linux/start-daemon.py diff --git a/test-head.py b/linux/test-head.py similarity index 100% rename from test-head.py rename to linux/test-head.py