I'm using Ubuntu with Gnome. My multimedia keys (play/pause, stop, etc) were working fine and then all of a sudden they stopped working.
In particular I'd like for them to work with Spotify.
I'm using Ubuntu with Gnome. My multimedia keys (play/pause, stop, etc) were working fine and then all of a sudden they stopped working.
In particular I'd like for them to work with Spotify.
If the multimedia keys were already working but stopped working, one or more of these solutions may help:
Restart gsd-media-keys
(see Troubleshooting below to see why this may be necessary)
Ubuntu 20.04+
systemctl --user restart gsd-media-keys.target
Previous versions
killall gsd-media-keys
Try closing all applications, then open the one you want to receive the multimedia keys first
Another workaround is to completely disable multimedia key support for certain applications
Chrome
chrome://flags/#hardware-media-key-handling
Disabled
Firefox
about:config
media.hardwaremediakeys.enabled
false
by clicking the toggle buttonMicrosoft Teams
There's no setting in the application to disable media keys, but you can use this workaround since it's an Electron app:
Copy the default desktop file
cp /usr/share/applications/teams.desktop ~/.local/share/applications/teams.desktop
Add a parameter to disable the media keys
sed -i 's/^Exec=teams %U/Exec=teams --disable-features=HardwareMediaKeyHandling %U/' ~/.local/share/applications/teams.desktop
If you've configured Teams to automatically start, you can use these steps:
Disable autostart from within Teams (3 dots menu > Settings > uncheck Auto-start application)
Create a custom autostart file
cp /usr/share/applications/teams.desktop ~/.config/autostart/teams-custom.desktop
Add a parameter to disable the media keys
sed -i 's/^Exec=teams %U/Exec=teams --disable-features=HardwareMediaKeyHandling %U/' ~/.config/autostart/teams-custom.desktop
Reset media key shortcuts to their default values
dconf reset /org/gnome/settings-daemon/plugins/media-keys/next
dconf reset /org/gnome/settings-daemon/plugins/media-keys/pause
dconf reset /org/gnome/settings-daemon/plugins/media-keys/play
dconf reset /org/gnome/settings-daemon/plugins/media-keys/previous
For even more control, see Playerctl
Use dbus-send
to list the applications which are configured via MPRIS to receive multimedia keys, e.g.:
$ dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep org.mpris
string "org.mpris.MediaPlayer2.spotify"
string "org.mpris.MediaPlayer2.chrome.instance22348"
In this example, you can see Spotify and Chrome (org.mpris.MediaPlayer2.chrome.instance22348
) are configured to receive the multimedia keys
org.mpris.MediaPlayer2.chromium.instance16163
but you don't have Chromium installed, it may be for an Electron-based application.Watch /var/log/syslog
tail -F /var/log/syslog
Press a media key (play, pause, stop, etc)
Look in the log for any pertinent messages, e.g.
Mar 26 12:23:17 hostname gsd-media-keys[1762]: Error calling method GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.mpris.MediaPlayer2.chrome.instance10062 was not provided by any .service files
In this example, you can see that the key is being sent to org.mpris.MediaPlayer2.chrome.instance10062
even though that application isn't in the list in step 1.
The solution (above) is to restart gsd-media-keys
.
If none of the above helped, make sure the media key shortcuts are all set to their default values
dconf read /org/gnome/settings-daemon/plugins/media-keys/next
dconf read /org/gnome/settings-daemon/plugins/media-keys/pause
dconf read /org/gnome/settings-daemon/plugins/media-keys/play
dconf read /org/gnome/settings-daemon/plugins/media-keys/previous
If the keys are all set to their default values, no output should be returned, e.g.:
$ dconf read /org/gnome/settings-daemon/plugins/media-keys/next
$ dconf read /org/gnome/settings-daemon/plugins/media-keys/pause
$ dconf read /org/gnome/settings-daemon/plugins/media-keys/play
$ dconf read /org/gnome/settings-daemon/plugins/media-keys/previous
$
dbus-send
to send the key to only that application. – bmaupin Jan 31 '22 at 13:11