Keys in X

Michael Brömer mib at telebel.de
Sun Nov 24 02:46:52 PST 2002


Am Freitag, 15. November 2002 23:29 schrieben Sie:
> I have one of those multimedia keyboards that have a bunch of extra keys
> to control some functions...and I want to assign some of them to, for
> example, start xmms or mozilla, lower and raise the volume, etc,
> anybody knows how to do this?

I got one of these Microsoft Keyboards. These additional keys are really
practical to have. I put them to work as follows: 
1.) When X is running open a console and type "xev". 
2.) Now press the key you would like to assign an action to.
3.) The output on your console should look something like this:
KeyPress event, serial 27, synthetic NO, window 0x2600001,
    root 0x78, subw 0x2600002, time 3046451476, (66,45), root:(1164,887),
    state 0x10, keycode 236 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 characters:  ""

KeyRelease event, serial 27, synthetic NO, window 0x2600001,
    root 0x78, subw 0x2600002, time 3046451587, (66,45), root:(1164,887),
    state 0x10, keycode 236 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 characters:  ""
...
Above is the output for my key labeled "E-Mail" (before assigning an event).
4.) Take note of the keycode generated by pressing the key. In the above
case the keycode is 236.
5.) Now assign an unused (below line 200) definition from 
/usr/X11R6/lib/X11/XKeysymDB to the keycode above by 
adding a line like 
keycode 236=XF86Mail
to your ~/.Xmodmap
6.) Restart X

If you now repeat step 1-3 you should get something like

KeyRelease event, serial 27, synthetic NO, window 0x2e00001,
    root 0x78, subw 0x0, time 3047100610, (-439,53), root:(659,895),
    state 0x10, keycode 236 (keysym 0x1008ff19, XF86Mail), same_screen YES,
    XLookupString gives 0 characters:  ""

You have now a key with the symbol "XF86Mail".

All that is left to do is to tell your windowmanager what to do if the key is
pressed.

I use KDE and there you just use "kmenuedit" to assign a key to start/switch
to an application.

The above procedure should also work for all applications that that allow you
to define keybord shortcuts for "in program actions". (kmixer -> "Mute", 
"Raise/Lower Volume, etc...)

Michael

-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-support' in the subject header of the message



More information about the blfs-support mailing list