Monday, February 22, 2010

Dell Latitude volume keys under Debian

Dell laptops have volume keys above the F-keys. This post explains how to enable them to control the volume.

First, the keys need to be recognized. One can set the right keyboard model in /etc/default/console-setup:
Other options can be set also, e.g.:
That ensures that keys are mapped to names like "XF86AudioMute". Names can be used in the menu file, where you put commands for alsamixer to rise/lower the volume. Your menu file could be named .menu/volume-keys (explained in "Debian menu system"):
?package(alsa): needs="X11" section="Apps/Sound/Xmms commands" \
        title="Master mute" \
        shortcut="XF86AudioMute" \
        longtitle="X MultiMedia System" \
        command="amixer set Master toggle"
?package(alsa): needs="X11" section="Apps/Sound/Xmms commands" \
        title="Master up" \
        shortcut="XF86AudioRaiseVolume" \
        longtitle="X MultiMedia System" \
        command="amixer set Master 5%+"
?package(alsa): needs="X11" section="Apps/Sound/Xmms commands" \
        title="Master down" \
        shortcut="XF86AudioLowerVolume" \
        longtitle="X MultiMedia System" \
        command="amixer set Master 5%-"
Run update-menus and refresh your window manager. Finished.

By choosing the right keyboard model, following lines are applied, which should already be present somewhere in /usr/share/X11/xkb/symbols:
    key    { [ XF86AudioMute         ] };
    key    { [ XF86AudioLowerVolume  ] };
    key    { [ XF86AudioRaiseVolume  ] };