Wiki (private)


 Blog Kornela 





Free Time



  1. xev - get keycodes
  2. create xmodmaprc
  3. load keymap with start of X
  4. create shortcuts in wm/application
  5. Scripts for ALSA and XMMS
Get the keycodes
If nessessary install xev (xevents).

Place your mouse over the little white window and press the keys for which you want to know the keycodes.

One Line should look something like this:
   KeyPress event, serial 30, synthetic NO, window 0x1c00001,
    root 0xdb, subw 0x0, time 1660226276, (89,82), root:(1690,103),
    state 0x0, keycode 235 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

   KeyRelease event, serial 30, synthetic NO, window 0x1c00001,
    root 0xdb, subw 0x0, time 1660226338, (89,82), root:(1690,103),
    state 0x0, keycode 235 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
The entry of interest for us is "keycode 235". Write them down and remember for which key it was (play, pause, the little ugly house-key).
Now create a file "xmodmaprc" to assign a keysym to each keycode:
   keycode 160=XF86AudioMute
   keycode 144=XF86AudioPrev
   keycode 164=XF86AudioStop
   keycode 162=XF86AudioPlay
   keycode 153=XF86AudioNext
   keycode 174=XF86AudioLowerVolume
   keycode 176=XF86AudioRaiseVolume
   keycode 236=XF86Mail
   keycode 178=XF86HomePage
   keycode 227=XF86Start
   keycode 161=XF86Search
   keycode 234=XF86Back
   keycode 231=XF86AudioRecord
You can test this with
  xmodmap xmodmaprc
Start "xev" again and check if the keysym is shown next to the keycode:
   keycode 234 (keysym 0x1008ff26, XF86Back)
Load keys with start of X
One way to do this (sure not the only way nor the best, but my way) is by executing xmodmap with the start of Xsession (if you use Xsession).

For a debian-like-system (debian,knoppix,ubuntu) for example go to

"/etc/X11/Xsession.d/" and edit
  • x99xorg-common_start for Xorg
  • x99xfree86-common_start for XFree
Before the command that starts the wm, I places my call to xmodmap:
   exec xmodmap /etc/X11/Xmodmaprc &
(do not forget the &, otherwise your wm will not start)
After restarting xdm (or apropriate) your can print out the keymap table to check if your custom keymap was loaded:
   xmodmap -pk
Window Manager / Applications
Generally you can use the above keysyms in the shortcut configs of your window manager just like any other key.

For KDE, start kcontrol, go to Regional and Accessibility, Keyboard Shortcuts. Or use the shortcut settings of your application (for example kmix and assign XF86AudioMute to mute Line In).

For Enlightenment copy the global keybindings (/usr/share/enlightenment/config/keybindings.cfg) to your local enlightenment directory and edit this one (~/.enlightenment/...).
Insert somethis like this
    __KEY XF86Search
    __ACTION __A_EXEC /usr/bin/firefox
Amarok is quite simple: Settings -> Configure global shortcuts, just use the keys.

ALSA and xmms are a little more complicated because they have no shortcut settings.
So I wrote a few shell scripts for the actions and configured my window manager to assign short cuts to these shell scripts.


I wanted to mute LineIn without using kmix or similar. The following shell-script toggles mute on LineIn in my second sound card:

   state=`amixer -c 1 get Line,0 | tail -1 | gawk '{print $6}'`

   if [ $state = "[on]" ];
        then amixer -c 1 sset Line,0 mute;
        else amixer -c 1 sset Line,0 unmute;
In KDE you add this script (say linein_toggle_mute.sh) to the Start-Menu and then assign a short cut to it. In enlightenment I added the following lines in my keybindings.cfg:
     __KEY XF86AudioMute
     __ACTION __A_EXEC /etc/alsa/scripts/line_toggle_mute.sh
Another thing for me was to easily toggle the capturing device from microphone to line in. The following script does this and opens a window in X that tells you which one is set at the moment:

   state=`amixer -c 1 get Mic,0 | tail -1 | gawk '{print $4}'`

   if [ $state = "[on]" ];
        then amixer -c 1 sset Line,0 cap;
        xmessage -center -timeout 1 "Capture-Device: Line in"
        else amixer -c 1 sset Mic,0 cap;
        xmessage -center -timeout 1 "Capture-Device: Microphone";
Again I assigned a key to this shell-scipt (like above).
Remember: "-c 1" means for card two (!). Change this to the correct soundcard for you or leave it out if you only have one.


XMMS creates a socket and there is a shell command (xmms-shell) from where you can (remote) control xmms.
I wrote a few shell scripts for play/pause/stop/backword/forward/volume.
You can download them and place them for example in /etc/xmms/scripts/ and assign like above keyboard shortcuts to them.