How to make use of the extra Multimedia keys in Laptops and Keyboards in Linux
I bought my notebook some months ago, OpenSUSE 10.2 turned out to have excellent hardware support for it and supported nearly all hardware, except those multimedia keys which come embedded on the notebook. This tutorial will show how you can easily add support for these keys to your Linux computer. This tutorial can not just be used for adding support for the extra multimedia keys on notebooks, but also for multimedia keyboards for Desktops.
In this tutorial we will add support for the "MediaDirect" key and the multimedia keys in the front of the Dell Inspiron.
Some keys such as Mute, Volume UP/Down are supported by default. We will add support for the additional keys and integrate the functionality with Amarok, my favorite media player.
First of all you will need the necessary program, xbindkeys. Download it and install it.
xbindkeys offers the following CLI interface:
xbindkeys 1.8.2 by Philippe Brochard
usage: xbindkeys [options]
where options are:
-V, --version Print version and exit
-d, --defaults Print a default rc file
-dg, --defaults-guile Print a default guile configuration file
-f, --file Use an alternative rc file
-fg, --file-guile Use an alternative guile configuration file
-h, --help This help!
-X, --display Set X display to use
-v, --verbose More information on xbindkeys when it run
-s, --show Show the actual keybinding
-k, --key Identify one key pressed
-mk, --multikey Identify multi key pressed
-g, --geometry size and position of window open with -k|-mk option
-n, --nodaemon don't start as daemon
Intially you need to create a stub configuration file
xbindkeys --defaults-guile > ~/.xbindkeysrc.scm
Now you need to identify the keycodes for the multimedia buttons, this is done by first invoking xbindkeys with the following switch
xbindkeys -mk
Some window pop ups, and now start pressing the buttons, one after another, when you press a button some information is printed on the console as depicted in the screenshot
The "m:0x10 + c:160" part of the output identifies the specific button to the computer. You can now open up the configuration file and associate a command with this. KDE is such an advanced environment that it allows users to interact with programs from the console through the Desktop Communications Protocol (DCOP). I had pressed the mute button, so I will associate the mute action in KDE with it, by invoking:
dcop kmix Mixer0 toggleMute 0
so in the configuration file this would look like:
"dcop kmix Mixer0 toggleMute 0 "
m:0x10 + c:160
So here are some parts of my configuration file, which associate different keys to different actions, like if I press the MediaDirect key amarok should open, If I press forward, it should go to the next playlist item, If I press previous it should go to the previous playlist item etc..
"amarok"
m:0x10 + c:237
"dcop amarok player play"
m:0x10 + c:162
"dcop amarok player prev"
m:0x10 + c:144
"dcop amarok player next"
m:0x10 + c:153
"dcop amarok player stop"
m:0x10 + c:164
So this is how basically you can add support for special multimedia keys to your Linux environment. Now the key mappings will not have an effect until you do not run xbindkeys in the background, you can do that by simply saying
xbindkeys &
You could also add it to your startup files so the key mappings work automatically.


