12

My volume mute, volume down, and volume up keys are working, but my previous, next, and play/pause keys are not.

I tried the solution posted here, but that doesn't seem to be the problem. All of my org.gnome.settings-daemon.plugins.media-keys settings seem to be appropriately prefixed by XF86:

enter image description here

Here's the output of pressing previous, next, play/pause, and mute in sequence:

$ xev
MappingNotify event, serial 39, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

FocusOut event, serial 39, synthetic NO, window 0x3600001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 40, synthetic NO, window 0x3600001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 40, 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 40, synthetic NO, window 0x3600001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 40, synthetic NO, window 0x3600001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 40, 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 40, synthetic NO, window 0x3600001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 40, synthetic NO, window 0x3600001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 40, 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 40, synthetic NO, window 0x3600001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 40, synthetic NO, window 0x3600001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 40, 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 40, synthetic NO, window 0x3600001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 40, synthetic NO, window 0x3600001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 40, 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  
$ sudo showkey -k
kb mode was ?UNKNOWN?
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
keycode 165 press
keycode 165 release
keycode 163 press
keycode 163 release
keycode 164 press
keycode 164 release
keycode 113 press
keycode 113 release
$ sudo showkey -s
kb mode was ?UNKNOWN?
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
0xe0 0x10 0xe0 0x90 
0xe0 0x19 0xe0 0x99 
0xe0 0x22 0xe0 0xa2 
0xe0 0x20 0xe0 0xa0 

How can I fix this?

/e1

I decided to look into this a bit more. Apparently, if you have a USB keyboard, you need to use evtest instead of showkey to get the proper scancodes:

$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:  Power Button
/dev/input/event1:  Power Button
/dev/input/event2:  CYKB16 USB Keyboard
/dev/input/event3:  CYKB16 USB Keyboard
/dev/input/event4:  USB Optical Mouse
/dev/input/event5:  HDA ATI HDMI HDMI/DP,pcm=3
/dev/input/event6:  HDA ATI HDMI HDMI/DP,pcm=7
/dev/input/event7:  HDA ATI HDMI HDMI/DP,pcm=8
/dev/input/event8:  HDA ATI HDMI HDMI/DP,pcm=9
/dev/input/event9:  HDA ATI HDMI HDMI/DP,pcm=10
/dev/input/event10: HDA ATI HDMI HDMI/DP,pcm=11
/dev/input/event11: HDA Intel PCH Front Mic
/dev/input/event12: HDA Intel PCH Rear Mic
/dev/input/event13: HDA Intel PCH Line
/dev/input/event14: HDA Intel PCH Line Out Front
/dev/input/event15: HDA Intel PCH Line Out Surround
/dev/input/event16: HDA Intel PCH Line Out CLFE
/dev/input/event17: HDA Intel PCH Line Out Side
/dev/input/event18: HDA Intel PCH Front Headphone
/dev/input/event19: Eee PC WMI hotkeys
Select the device event number [0-19]: 3
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x1130 product 0x7979 version 0x110
Input device name: "CYKB16 USB Keyboard"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 113 (KEY_MUTE)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
    Event code 116 (KEY_POWER)
    Event code 128 (KEY_STOP)
    Event code 140 (KEY_CALC)
    Event code 142 (KEY_SLEEP)
    Event code 143 (KEY_WAKEUP)
    Event code 144 (KEY_FILE)
    Event code 155 (KEY_MAIL)
    Event code 156 (KEY_BOOKMARKS)
    Event code 158 (KEY_BACK)
    Event code 159 (KEY_FORWARD)
    Event code 163 (KEY_NEXTSONG)
    Event code 164 (KEY_PLAYPAUSE)
    Event code 165 (KEY_PREVIOUSSONG)
    Event code 166 (KEY_STOPCD)
    Event code 171 (KEY_CONFIG)
    Event code 172 (KEY_HOMEPAGE)
    Event code 173 (KEY_REFRESH)
    Event code 217 (KEY_SEARCH)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1484332277.304213, type 4 (EV_MSC), code 4 (MSC_SCAN), value c00b6
Event: time 1484332277.304213, type 1 (EV_KEY), code 165 (KEY_PREVIOUSSONG), value 1
Event: time 1484332277.304213, -------------- SYN_REPORT ------------
Event: time 1484332277.304231, type 1 (EV_KEY), code 165 (KEY_PREVIOUSSONG), value 0
Event: time 1484332277.304231, -------------- SYN_REPORT ------------
Event: time 1484332277.640192, type 4 (EV_MSC), code 4 (MSC_SCAN), value c00b5
Event: time 1484332277.640192, type 1 (EV_KEY), code 163 (KEY_NEXTSONG), value 1
Event: time 1484332277.640192, -------------- SYN_REPORT ------------
Event: time 1484332277.640207, type 1 (EV_KEY), code 163 (KEY_NEXTSONG), value 0
Event: time 1484332277.640207, -------------- SYN_REPORT ------------
Event: time 1484332277.951137, type 4 (EV_MSC), code 4 (MSC_SCAN), value c00cd
Event: time 1484332277.951137, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1
Event: time 1484332277.951137, -------------- SYN_REPORT ------------
Event: time 1484332277.951153, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0
Event: time 1484332277.951153, -------------- SYN_REPORT ------------

I was able to verify that my keys were working by remapping them to letters:

$ cat /etc/udev/hwdb.d/90-custom-keyboard.hwdb 
evdev:input:b0003v1130p7979*
 KEYBOARD_KEY_c00cd=a
 KEYBOARD_KEY_c00b6=b
 KEYBOARD_KEY_c00b5=c
$ sudo udevadm --debug hwdb --update
$ sudo udevadm trigger

Now I can type letters with my previous, next, and play/pause keys. Next, I used xdotool to test keys out:

$ xdotool key XF86AudioLowerVolume
$ xdotool key XF86AudioRaiseVolume

both work, but none of the following do anything

$ xdotool key XF86AudioPlay
$ xdotool key XF86AudioNext
$ xdotool key XF86AudioPrev

This makes me think that Unity is dropping the ball with its media player integration, somehow. I'm not sure how to check that Unity is doing the right thing behind the scenes. Any ideas?

/e2

$ sudo lsusb -d 1130:7979
Bus 001 Device 003: ID 1130:7979 Tenx Technology, Inc. 
$ sudo lsusb -t
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
        |__ Port 7: Dev 3, If 0, Class=Wireless, Driver=btusb, 12M
        |__ Port 7: Dev 3, If 1, Class=Wireless, Driver=btusb, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
        |__ Port 5: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 5: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 6: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M

/e3

$ unity --version
unity 7.4.0

/e4

$ uname -a
Linux urithiru 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

/e5

$ banshee --version
Banshee 2.6.2 (2.6.2) http://banshee.fm
Copyright 2005-2017 Novell, Inc. and Contributors.
$ vlc --version
VLC media player 2.2.2 Weatherwax (revision 2.2.2-0-g6259d80)
VLC version 2.2.2 Weatherwax (2.2.2-0-g6259d80)
Compiled by buildd on lgw01-10.buildd (Mar 28 2016 02:49:24)
Compiler: gcc version 5.3.1 20160323 (Ubuntu 5.3.1-13ubuntu1)
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by the VideoLAN team; see the AUTHORS file.
Jeffrey
  • 231
  • 4
  • 15
  • If you want the text version of that GSettings path listing, you can get one with dconf dump /org/gnome/settings-daemon/plugins/media-keys/. (This happens to be a formidable way to save and restore GSettings/DConf data.) :-) – David Foerster Jan 13 '17 at 21:46
  • It's not Unity: it's the hardware module. What keyboard hardware do you have??? – Fabby Jan 15 '17 at 16:25
  • @Fabby I'm using a Rosewill Helios keyboard. It looks like it's using the usbhid driver (see edit). What makes you think it's a hardware issue? Wouldn't xdotool bypass any hardware issues? – Jeffrey Jan 15 '17 at 17:47
  • nope... xdotool just uses the underlying kernel modules... Have youcontacted techsupport@rosewill.com yet? I can't see anything about Linux compatibility... – Fabby Jan 15 '17 at 21:01
  • 2
    @Fabby The keyboard worked flawlessly with 14.04. I'll contact support to see if there's something particular about 16.04. – Jeffrey Jan 16 '17 at 01:20
  • Please [edit] the output of unity --version into you post. Thank you for helping us help you! – Elder Geek Jan 16 '17 at 16:03
  • To exclude that (or find out if-) it has anything to do with the dconf database, you could rename the directory ~/.config/dconf. *however*, you need to do it from another user account (or from a startup disk), since an exact copy will be created if you do it while logged in. If it doesn't change anything, simply rename it back again. – Jacob Vlijm Jan 17 '17 at 09:14
  • @ElderGeek Unity version is 7.4.0 – Jeffrey Jan 17 '17 at 13:43
  • @JacobVlijm No luck :( – Jeffrey Jan 17 '17 at 13:43
  • Thank you. Could you also edit in the output of uname -a This may be kernel related. Thank you. – Elder Geek Jan 17 '17 at 14:10
  • @ElderGeek Done. See e4 – Jeffrey Jan 17 '17 at 14:28
  • I'm not finding any 4.4.0-59 kernel, nor unity 7.4.0 bugs related to this. What application are you attempting to use when the previous, next, and play/pause keys don't function? – Elder Geek Jan 17 '17 at 21:09
  • @ElderGeek I've been trying it with Banshee and VLC. See e5 for their versions – Jeffrey Jan 18 '17 at 13:37
  • 1
    @JacobVlijm: A better idea would be to back up the Dconf database for media keys would be dconf dump, dconf reset -f and (to restore) dconf load. – David Foerster Jan 18 '17 at 14:29
  • @DavidFoerster WOW, commands that I didn't know about. Thanks! – Jacob Vlijm Jan 18 '17 at 14:50
  • I installed rhythmbox and it responds to the media keys correctly. It seems like my problem is the applications I've been trying to use. Both banshee 2.6.2 and VLC 2.2.2 do not respond to media keys in Ubuntu 16.04. – Jeffrey Jan 18 '17 at 13:50
  • Did you happen to have a different media player running at the same time intercepting the media keys? That's what happens on my system with Totem intercepting media keys that I had intended to control Gmusicbrowser or VLC. For VLC I had to configure the media keys as "global". – David Foerster Jan 18 '17 at 14:32
  • Sorry about the misunderstanding of your authorship. I was a bit on autopilot and only compared the profile images of the question and answer post authors (of which there is none for community wiki posts). – David Foerster Jan 18 '17 at 14:33
  • 1
    @DavidFoerster I made sure to close all media players before opening a new one, still didn't work. VLC won't let me set my play/pause, next, or previous buttons as the global hotkeys for those actions. I was able to set ALT + Play/Pause, ALT + Next, and ALT + Previous as the hotkeys, though. – Jeffrey Jan 18 '17 at 14:38

2 Answers2

4

The media keys do work (with rhythmbox). They do not work with banshee or VLC because there's a bug with banshee 2.6.2 and VLC 2.2.2 in Ubuntu 16.04.

A work around for VLC is to set a global hotkey.

Jeffrey
  • 231
  • 4
  • 15
  • Another fun discovery: It appears that this might be a unity-only bug. They work fine with gnome-shell. – Jeffrey Apr 09 '17 at 17:46
  • Using ubuntu-gnome-desktop, I noticed that having two instances open of Spotify also makes the media keys malfunction. – Jan M. Feb 08 '18 at 14:10
0

As @Jeffrey states in his answer the media keys work with rythmbox v.3.3. They also work in totem v.3.18.1 with no adjustment necessary.

Also known to work with the Rosewill RKM-1600RF (RF6560) 2.4GHz Wireless Multimedia keyboard

Elder Geek
  • 36,023
  • 25
  • 98
  • 183