Sunday, October 22, 2006

Extra Keys

Ever wanted to use those extra keys (like volume, Internet etc.) on your keybord? Well, there are many ways to do this. The easy way (KDE) : Open the Control Center, go to Regional and Accessibility -> Keyboard Layout and choose your keyboard from the list. The hard way: Use this if your keyboard isn't listed there or you dont use KDE (there IS an easy way in GNOME too, but since I dont use it, I dont know it). Open up a terminal and run "xev" in it. Press the key you want to use and carefully note the keycode displayed on the terminal. Now, use "xmodmap" to set the key to a Keysym. For example, let's say you opened xev and pressed the "Volume +" key, and got this output:

KeymapNotify event, serial 31, synthetic NO, window 0x0,
keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
       0   0   1   0   0   0   0   0   0   0   0   0   0   0   0   0

KeyRelease event, serial 31, synthetic NO, window 0x2c00001,
root 0x44, subw 0x0, time 1901594635, (767,132), root:(771,602),
state 0x0, keycode 144 (keysym 0x1008ff4a, XF86LaunchA), same_screen YES,
XLookupString gives 0 bytes:
Note the keycode. Now, lets say you want to set the Keysym of key 144 to XF86AudioRaiseVolume (you can find more Keysyms in /usr/X11R6/lib/X11/XKeysymDB (debian) or /usr/share/X11/XKeysymDB (fedora)). The following command will set the "Volume +" key to raise the volume (on KDE, this launches kmix and then raises the volume, with a huge dialog (which lasts for about 0.5 seconds) telling you the current volume):
# xmodmap -e "keycode 144 = XF86AudioRaiseVolume"
If you dont want the huge dialog, then you can use the panel's volume setter to use the key (set it's keysym to something arbitary like XF86Launch0) to increase the volume.

No comments: