This appears to be a common problem that does not have a solution: running Ubuntu (or Fedora or Manjaro), the primary media keys (back, play/pause, next) are not recognized or not consistently recognized by the OS.
My keyboard is set up so that the function buttons are secondary (must press FN button first), with the assigned keys (e.g., brightness, volume, media keys, eject) being primary (i.e., you press them once and they work). All but the media keys just work.
Various keyboard entry programs give differing feedback on whether the keys are assigned:
xbindkeys -k
[Nothing happens when I push the "next" key (F9 on my keyboard) or the "play/pause" key (F8 on my keyboard)]
xev
[Yields the below for either next or play/pause key]
KeymapNotify event, serial 37, synthetic NO, window 0x0,
keys: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FocusOut event, serial 37, synthetic NO, window 0x4400001,
mode NotifyGrab, detail NotifyAncestor
FocusIn event, serial 37, synthetic NO, window 0x4400001,
mode NotifyUngrab, detail NotifyAncestor
sudo showkey -k
keycode 164 press ## for play/pause
keycode 163 press ## for next
Using GNOME Settings
Navigating in the GUI to Settings>Devices>Keyboard Shortcuts
, and selecting "Next track" or "Play (or play/pause)", I can set the key command by clicking the text "Disabled" and then pressing the key. Notably, they are registered as Audio Play
and Audio Next
. However, when trying to assign a custom command to these same keys (after clearing them) in GNOME settings using the "+" button at the bottom of the GUI, neither key is recognized.
D-Conf
I also tried to edit the dconf entries for these two media keys, as suggested here, but it changed nothing.
###########################################
The bottom line is that I cannot get my media keys to work properly on GNOME. I checked to confirm that no browser has hijacked the media keys.
Using playerctl works for play, but I can't associate it with the play/pause button; as noted above, the GNOME settings "+" approach does not recognize the key, and I can't figure out how to associate keycode 164
with playerctl play-pause
.
Any solutions to this problem that are universally applicable would be great.
sudo killall gsd-media-keys
thenexec /usr/lib/gnome-settings-daemon/gsd-media-keys
– Kev Apr 02 '20 at 19:08