2

I've just installed Ubuntu 16.04 on my ThinkPad T450s and for some reason the media keys for volume and screen brightness are not giving any keycodes or keysyms (ie. XF86AudioRaiseVolume). But all the other media keys give the correct values.

What's weird is that the media keys still work fine in unity and gnome, it's just a problem when I use i3 because I can't map the volume keys to change the volume.

This is what xev returns for the volume down, volume up and volume mute keys:

Volume down:

FocusOut event, serial 33, synthetic NO, window 0x1a00001,
    mode NotifyUngrab, detail NotifyPointer

FocusIn event, serial 33, synthetic NO, window 0x1a00001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 33, 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 

Volume Up:

FocusOut event, serial 33, synthetic NO, window 0x1a00001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 33, synthetic NO, window 0x1a00001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 33, synthetic NO, window 0x0,
    keys:  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   0   

Volume mute:

FocusOut event, serial 33, synthetic NO, window 0x1a00001,
    mode NotifyUngrab, detail NotifyPointer

FocusIn event, serial 33, synthetic NO, window 0x1a00001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 33, 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 

As you can see, they are all the same. So I have no idea how unity or gnome can tell them apart. Just for reference I'll show the output for the mic off and wifi off media keys from xev:

KeyRelease event, serial 33, synthetic NO, window 0x1a00001,
    root 0xf6, subw 0x0, time 3107820, (-19,759), root:(625,798),
    state 0x0, keycode 198 (keysym 0x1008ffb2, XF86AudioMicMute), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 34, synthetic NO, window 0x1a00001,
    root 0xf6, subw 0x0, time 3112189, (-19,759), root:(625,798),
    state 0x0, keycode 246 (keysym 0x1008ff95, XF86WLAN), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

And I used to get similar results for the volume keys before installing ubuntu as well (I was using Arch).

The brightness keys don't work either, are these being overridden at some low level? Is there a way I can fix it so they return the correct value or is there some other way I can get the media keys working for ubuntu?

Update: This is what xev gives for the volume up and down keys while I'm running unity.

FocusOut event, serial 47, synthetic NO, window 0x4800001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 47, synthetic NO, window 0x4800001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 47, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   4   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeyRelease event, serial 47, synthetic NO, window 0x4800001,
    root 0xf7, subw 0x0, time 2182026, (-1217,972), root:(525,2104),
    state 0x0, keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 47, synthetic NO, window 0x4800001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 47, synthetic NO, window 0x4800001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 47, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeyRelease event, serial 47, synthetic NO, window 0x4800001,
    root 0xf7, subw 0x0, time 2185429, (-1217,972), root:(525,2104),
    state 0x0, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

When running unity, I also have unity-settings-daemon, unity-panel-service and unity-fallback-mount-helper. Could one of these be catching the event and adding the XF86 keysyms? None of these are running in i3.

In response to @Adaephon I have this in my i3 config:

# volume controls
bindsym XF86AudioRaiseVolume exec amixer -q  set Master playback 2%+ unmute
bindsym XF86AudioLowerVolume exec amixer -q  set Master playback 2%- unmute
bindsym XF86AudioMute exec amixer -q set Master mute
3

It looks like the keys in question are already grabbed globally by some other application. The three segments of output you get from xev are only related to the xev window loosing and reaquireing the focus, while the key is grabbed otherwise (See my post on the old i3 FAQ).

There are two likely causes, why xev might show an output like that and the keybinding does not work:

  1. First I would check, whether the keys in question - XF86AudioLowerVolume (keycode 122), XF86AudioRaiseVolume (keycode 123) and XF86AudioMute (keycode 121) - are already bound with bindsym (or bindcode) in your i3 configuration. Maybe it is only the bound command, which does not work.

    (Update) From the snippet of your i3 config this seems to be the case. I think 16.04 uses PulseAudio by default, so amixer might not even be installed. You can use pactl to change the volume on PulseAudio. To emulate your previous amixer settings try this:

    bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +2%; exec pactl set-sink-mute @DEFAULT_SINK@ 0
    bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -2%; exec pactl set-sink-mute @DEFAULT_SINK@ 0
    bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
    

    You can also use 1 instead of toggle on set-sink-mute, if you want to unmute only with the XF86AudioLowerVolume and XF86AudioRaiseVolume keys.

  2. If that is not the case, some other tool is grabbing those keys. One likely candidate is gnome-settings-daemon, unity-settings-daemon might be another. Also, some media players may try to bind these keys globally. I suggest checking the output of ps aux on a fresh i3 session to see what is automatically started. When you found the culprit you have essentially three options:

    • In most cases it should be possible to un-configure the key bindings. Probably the easiest solution, if you want to keep using whatever is grabbing the keys.
    • Make it work correctly. It may be that the program grabbing the key actually should do, what you want to do anyway (e.g. volume control), but for some reason it can not. For example: the program tries to change the volume with PulseAudio, while you are not actually using PulseAudio.
    • Stop it from starting. If you put it into autostart yourself (e.g. exec statement in your i3 configuration), you can just remove it. If it is automatically started due to some Ubuntu preset, it may require more work.

For gnome-settings-daemon you can use the instructions from my (other) post on the old i3 FAQ:

You should be able to get a list of bound keys with the following commands:

gsettings list-recursively org.gnome.settings-daemon.plugins.media-keys

You can then unset them by assinging an empy string

gsettings set org.gnome.settings-daemon.plugins.media-keys volume-mute ''
gsettings set org.gnome.settings-daemon.plugins.media-keys volume-down ''
gesttings set org.gnome.settings-daemon.plugins.media-keys volume-up ''

Alternatively, you can also use dconf:

dconf write /org/gnome/settings-daemon/plugins/media-keys/volume-mute "''"
dconf write /org/gnome/settings-daemon/plugins/media-keys/volume-down "''"
dconf write /org/gnome/settings-daemon/plugins/media-keys/volume-up "''"
  • Thanks for the answer! My i3 config has this in it: ``` # volume controls bindsym XF86AudioRaiseVolume exec amixer -q set Master playback 2%+ unmute bindsym XF86AudioLowerVolume exec amixer -q set Master playback 2%- unmute bindsym XF86AudioMute exec amixer -q set Master mute ``` I ran ps aux straight after starting i3 and didn't find any settings daemon at all. I did find gnome-keyring-daemon, gnome-screensaver, avahi-daeman and a couple of others that don't look suspicious though. – Yep_It's_Me May 11 '16 at 23:19
  • I've updated my question to give more info too. – Yep_It's_Me May 11 '16 at 23:29
  • @Yep_It's_Me So it is indeed i3 itself which is grabbing the keys. If you still can not change the volume, it is likely that the command itself does not work. Did you try running them in a terminal (e.g. amixer -q set Master playback 2%+ unmute)? I think 16.04 uses PulseAudio by default, so amixer might not even be installed. You can use pactl to change the volume on PulseAudio: pactl set-sink-volume @DEFAULT_SINK@ +2%, pactl set-sink-mute @DEFAULT_SINK@ toggle (or use 0 or 1 instead of toggle to disable or enable mute, respectively). – Adaephon May 12 '16 at 8:48
  • I added the bit about pactl to the answer. I left the rest unchanged as it may be of help to others finding your question due to similar but not identical issues. – Adaephon May 13 '16 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.