Ubuntu + Android: GSConnect, Media Controls, and System Volume via Phone Buttons
For relatively native Android integration on an Ubuntu GNOME desktop, GSConnect works well together with the KDE Connect Android app.
It provides media controls, file sharing, notifications, clipboard integration, and system-volume control over the local network.
Install GSConnect on Ubuntu
sudo apt update
sudo apt install gnome-shell-extension-gsconnectGSConnect is a GNOME Shell extension, so after installation it needs to be enabled.
Enable it with the GUI
Press the Super/Windows key, search for Extensions, and open the Extensions app.
Find GSConnect and enable it.
If the Extensions app isn’t installed:
sudo apt install gnome-shell-extension-prefsThen open it with:
gnome-extensions-appEnable it from the terminal
First confirm the extension is installed:
gnome-extensions listWe should see:
gsconnect@andyholmes.github.io
Enable it:
gnome-extensions enable gsconnect@andyholmes.github.ioCheck its status:
gnome-extensions info gsconnect@andyholmes.github.ioAfter installation or changes to GSConnect, logging out and back in to make sure we reload it.
Android
Install KDE Connect on Android.
Keep the phone and Ubuntu machine on the same local network, open KDE Connect on the phone, and pair it with the Ubuntu computer.
Enable the permissions and KDE Connect plugins you want to use.
Multimedia controls
KDE Connect’s Multimedia Control can detect applications on Ubuntu through MPRIS.
Example:
- VLC exposes playback and volume controls correctly.
- YouTube running in Chromium-based browsers exposes playback controls, but browser media volume is generally not writable through MPRIS.
This means the phone can pause or resume YouTube, but its player-volume control may do nothing.
Fortunately, controlling individual application volume isn’t necessary if you prefer using one global volume.
Controlling Ubuntu’s system volume
Inside:
KDE Connect → Multimedia Control → Devices
Ubuntu’s audio output appears as a device.
Changing its volume slider controls Ubuntu’s actual system/output volume, regardless of whether the sound is coming from YouTube, VLC, or another application.
This gives a much cleaner model:
YouTube ─┐
VLC ─┼─→ Ubuntu system volume → speakers/headphones
Other ─┘
There is, however, a GSConnect issue: although the Devices slider works, Android’s physical Volume + / Volume − buttons may not control that device.
VLC’s volume still works with the hardware buttons because that uses the application’s MPRIS volume instead.
Fixing Android hardware volume buttons
GSConnect’s system-volume information is missing the property KDE Connect Android uses to identify Ubuntu’s default audio output.
The fix is very small.
Find the installed GSConnect file:
FILE="$(find /usr/share/gnome-shell/extensions "$HOME/.local/share/gnome-shell/extensions" \
-path '*/gsconnect@andyholmes.github.io/service/plugins/systemvolume.js' \
-print -quit 2>/dev/null)"
printf '%s\n' "$FILE"It will normally be somewhere similar to:
/usr/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/plugins/systemvolume.js
Back it up
sudo cp -- "$FILE" "$FILE.bak"Edit it
sudoedit "$FILE"Find:
_updateCache(stream) {
const state = {
name: stream.name,
description: stream.display_name,
muted: stream.is_muted,
volume: stream.volume,
maxVolume: this._mixer.get_vol_max_norm(),
};We add const defaultSink = this._mixer.get_default_sink(); and enabled: defaultSink !== null && stream.name === defaultSink.name,
so it ends up like this:
_updateCache(stream) {
const defaultSink = this._mixer.get_default_sink();
const state = {
name: stream.name,
description: stream.display_name,
muted: stream.is_muted,
volume: stream.volume,
maxVolume: this._mixer.get_vol_max_norm(),
enabled: defaultSink !== null && stream.name === defaultSink.name,
};This tells KDE Connect Android which Ubuntu audio device is the currently active/default output.
Android can then apply its hardware volume-button changes to that device.
Reload and test
Log out of Ubuntu and log back in.
Then open:
KDE Connect → Multimedia Control → Devices
Select or view the Ubuntu output device and press the phone’s physical:
Volume +
Volume -
The buttons should now change Ubuntu’s system volume, rather than depending on whether the current application supports writable MPRIS volume.
The resulting setup is:
Android Volume ±
↓
KDE Connect
↓
GSConnect
↓
Ubuntu default audio output
↓
YouTube / VLC / anything else
Restoring the original file
If necessary:
sudo cp -- "$FILE.bak" "$FILE"
Then log out and back in.
One caveat: a future GSConnect package update may overwrite the modified file, so the small patch may need to be reapplied until the behavior is fixed upstream.