I have a Danish keyboard, but I find the English keyboard layout better to code with, so some time ago, I made some customizations using xmodmap to combine these. I wanted to use the English layout in general, but with the Danish characters æ, ø, and Ã¥ available using Alt Gr-;, Alt Gr-’ and Alt Gr-[, respectively. Also, I wanted to be able to use Alt Gr as a modifier for FVWM shortcuts.
This turned out to be tricky to accomplish, actually. If I set XkbLayout=us in xorg.conf (English layout), I couldn't get Alt Gr to work with the Danish Characters and as a modifier key at the same time. Mode_Switch or ISO_Level3_Shift either switched keycodes or acted as a modifier key, but not both. Even if I restored the previous Danish layout using dumps of keycodes and modifiers from xmodmap, it didn't work.
So I made a hack: Using XkbLayout=dk (Danish layout in xorg.conf), I overrided every keycode using xmodmap, see my .Xmodmap. This setup is unportable however, so follow these steps instead. I think it should work for other European layouts as well.
With XkbLayout=us, dump the keycodes:
xmodmap -pke > ~/Xmodmap-us
Switch back to the Danish layout and dump again:
xmodmap -pke > ~/.Xmodmap
Now hand edit .Xmodmap, replacing the keys that are different in Xmodmap-us ($%^&[]/ etc.), but ignore the modifier keys. The two layouts uses different modifier keys (Alt_R vs Alt Gr for instance), and I could only make it work with the Danish ones. By the way, vimdiff is your friend…
The Danish characters are handled like below. The last two arguments in each line are the one used when pressing Alt Gr (ISO_Level3_Shift). The 3rd and 4th argument are for Mode_Switch and not used here.
keycode 34 = bracketleft braceleft aring Aring aring Aring keycode 47 = semicolon colon ae AE ae AE keycode 48 = apostrophe quotedbl oslash Oslash oslash Oslash
Also, I have mapped the onehalf key (to the left of 1) to backtick (`) and the apostrofe key (to the right of ø) to tilde (~). Tweak it to match your preferences.
To use your new layout, the following must be run every time you log in (some distros do this automagically).
xmodmap ~/.Xmodmap
Now the Danish characters are available when you (rarely?) need them, and Alt Gr is still available as a modifier (Mod5).
———
Note: The add Lock/remove Lock stuff in .Xmodmap is necessary if you want to remap Caps Lock. I have remapped it to the Scroll Lock key, and then both the Escape key and Caps Lock key acting as Escape.
Related posts:
Comments
Leave a comment Trackback