From 8573e0a0a11696101ffaf7fa444d3353cc8b1952 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Thu, 7 Oct 2021 09:25:51 +0530 Subject: [PATCH 1/7] Add Linux support --- media_controls.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/media_controls.py b/media_controls.py index 13eeddd..01df44d 100644 --- a/media_controls.py +++ b/media_controls.py @@ -1,7 +1,17 @@ -import win32api -import win32con +import platform + +OS = platform.system() + +if OS == "Linux": + import os +elif OS == "Windows": + import win32api + import win32con + VK_MEDIA_PLAY_PAUSE = 0xB3 -VK_MEDIA_PLAY_PAUSE = 0xB3 def toggle_play(): - win32api.keybd_event(VK_MEDIA_PLAY_PAUSE, 0, 0, 0) + if OS == "Linux": + os.system('xdotool key XF86AudioPlay') + elif OS == "Windows": + win32api.keybd_event(VK_MEDIA_PLAY_PAUSE, 0, 0, 0) From a859e1fb0b2438bdbdba5294429aa83406c699d4 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Thu, 7 Oct 2021 09:52:48 +0530 Subject: [PATCH 2/7] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f3706e..67852b8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,18 @@ # Android Headset Media Controls for Windows -Python script that hacks in support for Android headset media control for Windows. +Python script that hacks in support for Android headset media control for Windows and Linux For more details on how this works, see the associated [blog post](http://www.roligheten.no/blog/programming/2018/07/02/media-controls-windows.html) ## Installation + +### On Windows Regardless of the platform the following is required 1. Python 3 or 2.7 (untested) installed on the system. 2. The packages pywin32 and sounddevice, installable via `pip install pywin32 sounddevice`. +### On Linux +1. Install python3 via `sudo apt install python3` +2. install packages sounddevice and numpy `pip3 install numpy` +3. install xdotool (emulates key presses) `sudo apt install xdotool` ### Windows 1. Download a copy of this repository from [here](https://github.com/Catuna/AndroidMediaControlsWindows/archive/master.zip) From 6b59d8d87c26167da161ce48bf4ac100e26ae40b Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Thu, 7 Oct 2021 09:53:04 +0530 Subject: [PATCH 3/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 67852b8..43a4d5c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Android Headset Media Controls for Windows +# Android Headset Media Controls for Windows and Linux Python script that hacks in support for Android headset media control for Windows and Linux For more details on how this works, see the associated [blog post](http://www.roligheten.no/blog/programming/2018/07/02/media-controls-windows.html) From 56eb134e063b1293245c950202ad7ea38ceaa2f2 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Thu, 7 Oct 2021 11:45:52 +0530 Subject: [PATCH 4/7] Update README.md --- README.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 43a4d5c..6446c0c 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,10 @@ Regardless of the platform the following is required 2. The packages pywin32 and sounddevice, installable via `pip install pywin32 sounddevice`. ### On Linux 1. Install python3 via `sudo apt install python3` -2. install packages sounddevice and numpy `pip3 install numpy` +2. install packages sounddevice and numpy `pip3 install numpy sounddevice` 3. install xdotool (emulates key presses) `sudo apt install xdotool` +4. Install pypy, found to give performence improvements; recommended but not required, you can use the regular python interpreter: `sudo apt install pypy3` +if run via pypy, install requirements using `pypy3 -m pip install numpy sounddevice` ### Windows 1. Download a copy of this repository from [here](https://github.com/Catuna/AndroidMediaControlsWindows/archive/master.zip) @@ -37,5 +39,16 @@ Regardless of the platform the following is required 7. Restart your computer. At this point you should find 'pythonw.exe' running in the task mananger under 'Background Processes' and the program should function. -### Linux and Mac -Sorry, the script currently only works for Windows at the moment, feel free to contribute code for other platforms if you have the time. +### Linux + +1. Clone the repo via `git clone ` or download and extract the zip as listed in the first step of the windows install +2. Place it somewhere safe, maybe in the documents folder +3. cd into the directory +4. start the script via `python3 run.py` or `pypy3 run.py`, test if it works if you want to +5. test if it works +6. then add it to startup apps, on PopOS 21.10, you can do this via the startup apps application + +### Mac +Not yet supported + + From af510cafcac8581af37106c24b0eec2a4cc81a29 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Sun, 10 Oct 2021 18:02:06 +0530 Subject: [PATCH 5/7] Add a note regarding wayland support --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6446c0c..d3f11d1 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Regardless of the platform the following is required 1. Python 3 or 2.7 (untested) installed on the system. 2. The packages pywin32 and sounddevice, installable via `pip install pywin32 sounddevice`. ### On Linux +#### Note: This only works on X11, No wayland Support as of now 1. Install python3 via `sudo apt install python3` 2. install packages sounddevice and numpy `pip3 install numpy sounddevice` 3. install xdotool (emulates key presses) `sudo apt install xdotool` From eed50a75073e49324c83f7e234dc0d3cb80bf14f Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Tue, 7 Dec 2021 12:39:46 +0530 Subject: [PATCH 6/7] Update README.md Correct PopOS version Number --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3f11d1..8fb5a59 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ if run via pypy, install requirements using `pypy3 -m pip install numpy sounddev 3. cd into the directory 4. start the script via `python3 run.py` or `pypy3 run.py`, test if it works if you want to 5. test if it works -6. then add it to startup apps, on PopOS 21.10, you can do this via the startup apps application +6. then add it to startup apps, as of Pop!_OS 21.04, you can do this via the startup apps application ### Mac Not yet supported From a3df4b7003348104412e8532f50f681fe3a173af Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Tue, 7 Dec 2021 12:41:28 +0530 Subject: [PATCH 7/7] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8fb5a59..f3f7927 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,22 @@ For more details on how this works, see the associated [blog post](http://www.ro ## Installation -### On Windows +### Dependencies + +#### On Windows Regardless of the platform the following is required 1. Python 3 or 2.7 (untested) installed on the system. 2. The packages pywin32 and sounddevice, installable via `pip install pywin32 sounddevice`. -### On Linux -#### Note: This only works on X11, No wayland Support as of now +#### On Linux +##### Note: This only works on X11, No wayland Support as of now 1. Install python3 via `sudo apt install python3` 2. install packages sounddevice and numpy `pip3 install numpy sounddevice` 3. install xdotool (emulates key presses) `sudo apt install xdotool` 4. Install pypy, found to give performence improvements; recommended but not required, you can use the regular python interpreter: `sudo apt install pypy3` if run via pypy, install requirements using `pypy3 -m pip install numpy sounddevice` +### Running and Installing + ### Windows 1. Download a copy of this repository from [here](https://github.com/Catuna/AndroidMediaControlsWindows/archive/master.zip) 2. Extract to an appropriate location on your system, where doesn't matter as long as you don't accidentally delete it.