This program does two things:
- Shares audio from connected device to the pc, supressing it on the original device.
- Exposes Android media playback over MPRIS so desktop notification panels (swaync, dunst, waybar, etc.) can display and control it.
An alternative sync is an A2DP sink but that introduces latency, lag & quality loss if you have multiple devices connected over bluetooth e.g. Xbox Controller, Wireless headphones (connected to PC) and Phone (streaming audio to PC). If you only connect your phone (e.g. have wired headphones and use mouse&keyboard for that game), you may not need this/scrcpy at all and A2DP might be sufficient.
For now, this only works on linux. It will not work on Windows or MacOS, since they don't use MPRIS, but their own thing. On those OSes you can just do scrcpy --no-window --no-video and you get the audio part without the media controls.
Windows support or MacOS support might be possible but it is not implemented (for now).
You need to install scrcpy (github, repology).
Requires GNU/Linux with D-Bus, adb connected to a device, and scrcpy in PATH.
audiocpy starts scrcpy --no-window --no-video alongside the controller and tears it down on exit; you can pass --detach to manage scrcpy yourself.
Run audiocpy --help for all options.
Album art is resolved offline via Android MediaStore only, with cached images stored in ~/.cache/scrcpyMediaController.
Fedora:
sudo dnf install android-tools scrcpy python3-devel gobject-introspection-devel cairo-gobject-devel gcc pkg-configDebian/Ubuntu:
sudo apt install adb scrcpy python3.12-dev libgirepository1.0-dev libcairo2-dev pkg-config gccThe compiler and dev headers are only needed at install time to build pydbus/PyGObject. They can be removed afterwards.
With the system dependencies above in place:
uv tool install git+https://github.com/AzlanCoding/scrcpyMediaController
audiocpygit clone https://github.com/AzlanCoding/scrcpyMediaController
cd scrcpyMediaController
uv sync
uv run audiocpy- Fetching album art for Google Chrome, AntennaPod and Spotify
- the only reliable found method is fetching through Android MediaStore (+ caching), which does not work for these apps
- Shuffle/Loop controls
- at one point they were implemented, but they didn't work. Removed for now, may be reintroduced later.
- Thanks to the scrcpy repository for the icon (
icon.png). - Thanks to @KraXen72 for the pull request (the script was rewritten to move to uv and add some support for album art).
