If you’ve ever poked around in the KDE or GNOME control panels, you know that the X11 keyboard system is very customizable and, as the KDE keyboard controls clearly show, that it’s all done using a little command named
The problem is, Google isn’t very helpful if you want to use this tool directly. All the results seem to tell you to read the raw config files or only give you single, purpose-specific examples.
The good news is that your system actually DOES include a single file equivalent to (and probably the source for) the listings you get in the GUI tools:
For those who haven’t used KDE and need an example, here’s the command I run on login (These can also be specified in xorg.conf via Option directives, but I prefer something I can keep in my roaming profile):
setxkbmap \ -variant altgr-intl \ -option \ -option compose:rctrl \ -option lv3:ralt_switch \ -option terminate:ctrl_alt_bkspc \ -option eurosign:e \ -option nbsp:level3n
As usual, the backslashes are only necessary if you’re splitting it across multiple lines. Here’s what they actually do when used with a
- -variant altgr-intl
- The default variant of the US 104 layout doesn’t have tertiary symbols like ¢ and þ for AltGr to access, so I’m selecting one that does.
- You can also use the
intlvariant here but, for some reason, it maps ² to AltGr+2 and ³ to AltGr+3 but ¹ to AltGr+Shift+1.
- An empty
-optionresets the layout options so I’m starting from a clean slate.
- -option compose:rctrl
- This remaps the
Compose, so I can access glyphs like ½, ±, and é by typing “
Ctrl 1 2” or “
Ctrl + -" or "
Ctrl e '“.
- -option lv3:ralt_switch
- This remaps
AltGr, granting access to ¬ (AltGr+\) for making ¬_¬ smileys and giving me simpler key combos for commonly-used glyphs like µ (AltGr+m) and © (AltGr+c).
- You can also use
ralt_switch_multikeyhere to make Shift+AltGr the Compose key on compact keyboards but my muscle memory has already settled on
Control_R. (Note: Make sure you press Shift first or it’ll just send an ordinary AltGr+Shift)
- Note:If anyone knows why ¬ is no longer on
AltGr+`, please leave a comment.
- -option terminate:ctrl_alt_bkspc
- Restore Ctrl+Alt+Backspace as the “Kill X Server” shortcut without relying on a superior but root-privileged and Linux-only config tweak.
- (Again, I like settings I can store in my roaming profile)
- -option eurosign:e
- I’m Canadian, so on the occasions I need to type €, it can take me a while to remember that it has two cross-bars so I know to use “
Compose e =“. Since my muscle memory already uses “
Compose e '” for é anyway, let’s remap
- -option nbsp:level3n
- Lets me type non-breaking spaces with
AltGr+Spacefor those times when
doesn’t have special meaning.
level3lets me type thin non-breaking spaces with
The beauty of doing things this way is that you’re unlikely to break things badly. It’s nearly impossible to paint yourself into a corner using variants and options alone (It’s models and layouts you have to be careful with) and, if you ever try to apply your settings to a keyboard they weren’t intended for, an unrecognized variant will abort the process and unrecognized options will simply have no effect.
Have fun and, if you’ve got any other interesting keyboard tweaks, share them in the comments. If I like one that applies to
us104 enough to use it myself, I’ll update the example in the post body.