45.1 Mapping a Key
First find the keycode of the key you wish to map. Do this by running xev and press the key you wish to map (e.g., the Windows key) and look for the keycode:
KeyPress event, serial 22, synthetic NO, window 0x4000001,
root 0x26, subw 0x0, time 24756 22836, (129,34), root:(139,245),
state 0x58, keycode 115 (keysym 0xffed, Meta_L), same_screen YES,
Create /home/kayon/.Xmodmap
and map the keycode to any unused
keysym. For example, assuming your keyboard has function keys F1–F12
then generally F13 and beyond are not used, so lets use F15:
For a complete list of keysyms, see
/usr/X11R6/include/X11/keysymdef.h
. (You omit the XK_
prefix
when using them with xmodmap).
Run xmodmap ~/.Xmodmap
. You can do this interactively instead with:
Now you should be able to bind F15 to any action with, for example, metacity.
Even better, sawfish, for example supports custom modifier keys (i.e., modifiers apart from Ctrl, Alt, and Shift- and knows about Hyper). You can map the left windows key:
Then use Hyper_L
for all bindings related to the window manager
(thus freeing Ctrl and Alt-based bindings). This makes it a perfect
window manager key.
I end up with /home/kayon/.Xmodmap
containing:
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0