[moon] home
IPv4

Erlkönig: Xmodmap

Stuff to do to yourself with xmodmap.
parent
[parent webpage]

server
[webserver base]

search
[search erlkonig webpages]

trust
[import certificates]


homes
[talisman]
[zoion]

Some guy on stackoverflow.com asked about how to establish a Super modifier key. After writing a really long answer, I decided to archive it here for other folks interested in doing things with adding Super and Hyper, using Dead Keys, and so forth.

The first thing to do is see if you already have a Super modifier key. Run "xmodmap -pm" to see what your modifiers currently are. Here's a common output:

$ xmodmap -pm xmodmap: up to 4 keys per modifier, (keycodes in parentheses): shift Shift_L (0x32), Shift_R (0x3e) lock Caps_Lock (0x42) control Control_L (0x25), Control_R (0x69) mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd) mod2 Num_Lock (0x4d) mod3 mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf) mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)

In the output above, a bunch of keys are already mapped to Super, with (hex) keycodes 0x85, 0x86, 0xce, and 0xcf. To see if anything on your keyboard happens to be one of those keys (which isn't always the case), run "xev" in a terminal and move your mouse pointer into "xev"'s mostly-white input window, and try different keys. Typical output looks like this for keys (try control and shift to see examples) - pay particular attention to the third line with the keycode and keysym name, here 64 and Meta_L:

KeyPress event, serial 42, synthetic NO, window 0xe600003, root 0x6b6, subw 0x0, time 2232472454, (-1,167), root:(871,683), state 0x0, keycode 64 (keysym 0xffe7, Meta_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False

Find the "keycode" part and covert it to base 16. If you've hit one of the Supers, your converted code will match one of the (in the example above, four) hex keycodes, and show Super_L or Super_R instead of the Meta_L shown above.

If you don't have any keys mapped to Super, or it turns out that none of them exist on your keyboard, then use xev to find the keycode for the key you want to use for Super (CapsLock might be a good choice for some folks), then use xmodmap or some other tool in your desktop's UI to set it up. The latter is outside of the scope of this reply, but with xmodmap, you could just make a file named .Xmodmap in your home directory with this in it:

! note: replace the 0xff below with your *actual* Super_L key's keycode. ! note: whether to use mod3 or mod4 depends on your environment. keycode 0xff = Super_L clear mod4 add mod4 = Super_L

Apply the results with "xmodmap ~/.Xmodmap". Many X startups will automatically apply these for you. If you're using Ubuntu Unity, look up Startup Applications in the Dash and add one for that same command. I'm not sure if "~" works in the context, you might want to try $HOME or just use your home directory there. It ends up producing a file in ~/.config/autostart/xmodmap.desktop like this one (erlkonig = me; put your home in instead):

$ cat ./.config/autostart/xmodmap.desktop [Desktop Entry] Type=Application Exec=/usr/bin/xmodmap /home/erlkonig/.Xmodmap Hidden=false NoDisplay=false X-GNOME-Autostart-enabled=true Name[en_US]=Xmodmap Keymap Settings Name=Xmodmap Keymap Settings Comment[en_US]=Set Keyboard Bindings Comment=Set Keyboard Bindings

You can verify the results with "xmodmap -pm" or "xev". Here's the output for the former for my environment (which probably won't match what you'd want yourself).

$ xmodmap -pm xmodmap: up to 4 keys per modifier, (keycodes in parentheses): shift Shift_L (0x32), Shift_R (0x3e) lock Caps_Lock (0x7f) control Control_L (0x25) mod1 Meta_L (0x40), Meta_L (0xcd) mod2 Alt_L (0x6c), Alt_L (0xcc) mod3 Super_R (0x69), Super_L (0x85), Super_R (0x86), Super_L (0xce) mod4 Hyper_L (0x42), Hyper_L (0xcf) mod5 Num_Lock (0x4d) $

Hyper replaces CapsLock (which I've moved elsewhere); I use it for window manager functions, like Hyper-f to "front" a window, Hyper-r to resize, etc.

For another random(ish) example of what you can with xmodmap, here's a keymap that map whatever keycode 78 is to Mode_switch, and then allow you to combine it with ', ", `, and ~ to enter prefixes that make your next vowel have the similar diacritic on them. You can also use the Mode_switch with a to get æ, d to get ð, ? to get ¿, and some others.

! note: 78 is probably not the keycode most would want here; pick your own :-) keycode 78 = Mode_switch ! no mods shift mode-switch shift+mode-switch keysym a = a A ae AE keysym d = d D thorn THORN keysym n = n N ntilde Ntilde keysym o = o O oslash Oslash keysym t = t T eth ETH keysym s = s S ssharp keysym 0 = 0 parenright degree keysym 6 = 6 asciicircum dead_circumflex keysym 8 = 8 asterisk multiply keysym apostrophe = apostrophe quotedbl dead_acute dead_diaeresis keysym grave = grave asciitilde dead_grave keysym comma = comma less dead_cedilla guillemotleft keysym period = period greater NoSymbol guillemotright keysym slash = slash question NoSymbol questiondown keysym 1 = 1 exclam NoSymbol exclamdown keysym equal = equal plus notequal plusminus

for more information use "man xmodmap".

disencrypt lang [de jp fr] diff backlinks (sec) validate printable
Klein bottle for rent; inquire within.
[ Your browser's CSS support is broken. Upgrade! ]
alexsiodhe, christopher north-keys, christopher alex north-keys