Here is how to setup your multimedia keyboard if your are using Fedora Core 4 and KDE.
1 ) Get the keycode of your multimedia keys
Start xev. This program traps the keyboard events and display information about them. Among this information you will find the keycode which will be needed later.
A sample of the output is :
KeyRelease event, serial 28, synthetic NO, window 0x1200001,
root 0x48, subw 0x0, time 1985516936, (163,-13), root:(166,60),
state 0x10, keycode 162 (keysym 0x1008ff14, XF86AudioPlay), same_screen YES,
XLookupString gives 0 bytes:
...
KeyRelease event, serial 31, synthetic NO, window 0x1200001,
root 0x48, subw 0x0, time 1985521875, (163,-13), root:(166,60),
state 0x10, keycode 234 (keysym 0x1008ff16, XF86AudioPrev), same_screen YES,
XLookupString gives 0 bytes:
...
KeyRelease event, serial 31, synthetic NO, window 0x1200001,
root 0x48, subw 0x0, time 1985522575, (163,-13), root:(166,60),
state 0x10, keycode 233 (keysym 0x1008ff17, XF86AudioNext), same_screen YES,
XLookupString gives 0 bytes:
Here I pressed the Play/Pause key, then next and previous key on my keyboard.
From the output we see that Play/Pause Key has a keycode of 162.
Do the same for the +, - and mute buttons.
2 ) Creating the .Xmodmap file
Create the file and populate it with the keycode found previously :
keycode 234 = XF86AudioPrev
keycode 162 = XF86AudioPlay
keycode 233 = XF86AudioNext
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 160 = XF86AudioMute
For other XF86 references, look <a href="http://wiki.linuxquestions.org/wiki/XF86_keyboard_symbols">here</a>.
Once this file is created, load it : xmodmap ~/.Xmodmap and don't forget to add to your rc files so it will be loaded automatically when you loggon.
3 ) Configure keyboard in Control Center
We have 2 categories of command to define here. The first ones will concern the player. We will do it for Amarok but it works with other players (xmms, noatun...). The second ones will control the volume. This will be effective system wide.
3.1 ) Controling the Player
Open Control Center and click on "Regional and Accessibility", then "Input Actions"
Create a new group ( I called mine Multimedia keys ). Then create a new action.
Give it a name and select Keyboard shortcut -> DCOP call (simple) as the action type.
Click on keyboard shortcut, then map the key you want by pressing it.
Finally click on DCOP call Settings. Remote application will be amarok, Remote object will be player, Call function will be playPause. If you don't know these variables, you can click on "run KDCOP" and browse remote application, object and function.
Map as many multimedia keys as you wish then click apply.
<img border='0' hspace='5' src='/blog/uploads/xmodmap_khotkeys.jpg' alt='' />
3.2 ) Controlling the sound
The sound is controled via the amixer command. It is extremely simple. To mute, you can type amixer set Master toggle. To lower volume, type amixer set Master 1- and to raise volume, amixer set Master 1+.
So what we need to do is to add these keys/actions in khotkeys.
Go back to Control Center and add a new action in "Input Actions".
Give it a name and select "Keyboard shortcut -> Command/URL (simple)"
Map your key in Keyboard shortcut
Then type the command in "Command/URL to execute".
<img width='950' height='531' border='0' hspace='5' src='/blog/uploads/xmodmap_khotkeys2.jpg' alt='' />