Ubuntu – Media Keys not working on Ubuntu 17.10


I'm running a pretty-much brand-new Ubuntu 17.10 installation on a Thinkpad T470s.

Whenever I'm hitting one of the media keys (play/pause, skip, etc) on any one of my keyboards or bluetooth-headset I'm seeing this icon:

popup on media key indicating no action allowed

flash on the monitor but none of my media players react.

The keys are recognized in showkey:

~$ sudo showkey -k
press any key (program terminates 10s after last keypress)...
keycode 163 press
keycode 163 release
keycode 165 press
keycode 165 release
keycode 164 press
keycode 164 release

But they don't show up in xev.

Best Answer

This whole issue looks like an "it's not a bug, it's a FEATURE" present from Gnome.

In short: when you press a media button it generates a keycode which is then translated into a command. Let's say you press a Play/Pause button. It generates a keycode 162 and a command XF86AudioPlay.

Now almost every media application that may be waiting for this event (be it VLC, totem, kodi, spotify etc.) expect to receive pure XF86AudioPlay command. And what Gnome does? It intercepts this command and translate it into it's own command "play". Because of this neither xev nor xbindkeys show this event properly - they never receive a command they can understand.

When you press a media button Gnome receives the command and checks if there is any app that its recognized as capable of receiving this command. If there is (let's say totem, rhytmbox, maybe VLC) it sends "play" that should work. If there is no app recognised as capable of receiving this command Gnome will show the sign that is attached to first post and won't send any command anywhere.

The solution is simple - make Gnome unable to intercept media key events. Install dconf-editor , go to org.gnome.settings-daemon.plugins.media-keys and change any button that should work from XF86SomeExample (e.g., XF86AudioPlay) to none (''). This way any app should receive key command directly.

Related Question