Laptop volume controls (fn keys) not working on Openbox (Debian 9 stretch – crunchbangplusplus)

Published: July 25, 2017 | Last Modified: October 3, 2017

On a clean install of the excellent http://crunchbangplusplus.org/ linux distro (Debian 9 stretch AMD64) my Asus laptop's volume control fn shortcut keys were not working for volume up, down and toggling the mute.

In this distro it's using pulseaudio and pavucontrol to control the audio and volume. The little applet which sits in the tint2 toolbar is mate-volume-control-applet - so it's a bit of a mixed bag. You can control pavucontrol via the command line with pactl --command and fortunately the excellent Openbox windows manager lets you set keybindings in rc.xml - see http://openbox.org/wiki/Help:Configuration - so I just added:

<!-- Keybindings for volume -->
<keybind key="XF86AudioRaiseVolume">
<action name="Execute">
<command>pactl set-sink-volume 0 +10%</command>
</action>
</keybind>
<keybind key="XF86AudioLowerVolume">
<action name="Execute">
<command>pactl set-sink-volume 0 -10%</command>
</action>
</keybind>
<keybind key="XF86AudioMute">
<action name="Execute">
<command>pactl set-sink-mute 0 toggle</command>
</action>
</keybind>