How to use your favorite multimedia keyboard's favorite multimedia keys with Linux
All you need to do, is define mappings for these keys. Just follow these steps:
Run xev from a terminal window
$> xev
This is what you will get:
[karan@karan ~]$ xev
Outer window is 0x3200001, inner window is 0x3200002
PropertyNotify event, serial 8, synthetic NO, window 0x3200001,
atom 0x27 (WM_NAME), time 754523327, state PropertyNewValue
PropertyNotify event, serial 9, synthetic NO, window 0x3200001,
atom 0x22 (WM_COMMAND), time 754523327, state PropertyNewValue
.
.
.
.
After the long list of messages, xev will open a little window in a
corner of your screen, and will be ready to accept input from all input
devices.Outer window is 0x3200001, inner window is 0x3200002
PropertyNotify event, serial 8, synthetic NO, window 0x3200001,
atom 0x27 (WM_NAME), time 754523327, state PropertyNewValue
PropertyNotify event, serial 9, synthetic NO, window 0x3200001,
atom 0x22 (WM_COMMAND), time 754523327, state PropertyNewValue
.
.
.
.
Now press the keys you want to map
When you press the keys, you will get the keycode output from xev.
For eg. i press the "search" key on my keyboard, and this is what I get:
KeyRelease event, serial 30, synthetic NO, window 0x3200001,
root 0xd4, subw 0x0, time 754840349, (-658,866), root:(2012,892),
state 0x0, keycode 229 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
root 0xd4, subw 0x0, time 754840349, (-658,866), root:(2012,892),
state 0x0, keycode 229 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
We are interested in the keycode Note down the values that you get for the different keys that you press.
Change /usr/X11R6/lib/X11/XKeysymDB
Add the following lines to the bottom of this file:
vol_up :10090000
vol_down :10090001
mute :10090002
.
.
The nos. can be anything, just keep them high, so that they don't clash
with other values. The above lines specify that you will be referring
to keys vol_up, vol_down, mute,.... so that system should watch out for
these referrals.vol_down :10090001
mute :10090002
.
.
Create/Update your .xmodmap file in your home dir
keycode 176 = vol_up
keycode 174 = vol_down
keycode 160 = mute
keycode 174 = vol_down
keycode 160 = mute
Run xmodmap from a terminal
$> xmodmap ~/.xmodmap
Now you have made these keys recognizable, but they are still not mapped to any actions. I have mapped these keys to the SoundMixer applet running in my taskbar. Map them however you want.

<< Home