Audio Keys

The audio keys or multimedia keys are simple to add. Add the following keybindings to your file ~/.config/openbox/lxde-rc.xml:

    <keybind key="XF86AudioRaiseVolume">
      <action name="Execute">
        <command>amixer set Master 5%+ unmute</command>
      </action>
    </keybind>
    <keybind key="XF86AudioLowerVolume">
      <action name="Execute">
        <command>amixer set Master 5%- unmute</command>
      </action>
    </keybind>
    <keybind key="XF86AudioMute">
        <action name="Execute">
            <command>amixer set Master toggle</command>
        </action>
    </keybind>

As you can see, it uses the key ids XF86AudioRaiseVolume, XF86AudioLowerVolume and XF86AudioMute. It uses the comman amixer to actually change the volume etc.

Credits go to: Create LXDE Fn Key Shortcut for Brightness & Volume on Archlinux .

Brightness

I’m using an Apple MacBook Pro - and this means, the brightness is controlled through the kernel driver apple-gmux. You can simply change the brightness by writing to special files under the /sys filesystem tree.

In order to make it simpler to add the key binding, the following shell script can be used:

#!/bin/sh

if [ ! -e /sys/class/backlight/gmux_backlight ]; then
    modprobe apple-gmux
fi

STEP=5000
BL_FILE=/sys/class/backlight/gmux_backlight/brightness
VALUE=$(cat $BL_FILE)
MAX=$(cat /sys/class/backlight/gmux_backlight/max_brightness)

echo "Current: $VALUE"
echo "Max: $MAX"

NEW=$VALUE

if [ "$1" = "-" ]; then
    NEW=$(echo $VALUE - $STEP | bc)
elif [ "$1" = "+" ]; then
    NEW=$(echo $VALUE + $STEP | bc)
fi

if [ $NEW -gt $MAX ]; then
    NEW=$MAX
elif [ $NEW -lt 0 ]; then
    NEW=0
fi

echo "New: $NEW"
echo $NEW > $BL_FILE

It first loads the kernel module “apple-gmux” if necessary, reads out the current value and the maximum value. In case the first argument is a “+” it calculates the new value using bc.

Please note, that this script needs to be run as root, so you probably want to set it up via sudo using e.g. the following rule:

myuser ALL=(ALL:ALL) NOPASSWD: /home/myuser/backlight

And the final bit is the keybindings for XF86MonBrightnessUp and XF86MonBrightnessDown in ~/.config/openbox/lxde-rc.xml:

    <keybind key="XF86MonBrightnessUp">
        <action name="Execute">
            <command>sudo /home/myuser/backlight +</command>
        </action>
    </keybind>
    <keybind key="XF86MonBrightnessDown">
        <action name="Execute">
            <command>sudo /home/myuser/backlight -</command>
        </action>
    </keybind>

Reload openbox configuration

Use openbox-lxde --reconfigure in order to reload the new keybindings and use them immediately.