Caps Lock as a Mod Key
A mod key modifies the behaviour of other keys. When you use window managers which are mostly controlled via the keyboard, choosing yours is everything.
1 Rationale
Mod key undoubtedly stands for "modifier key". My favourite one is the Caps Lock. The reason I like to set Caps Lock as the mod key is that Caps Locks isn't a very useful key, when you think about it. Worse still, it often gets in the way. Typing a sequence a upper-case characters can very easily be achieved holding the Shift key. However, how often does it happen that you accidentally press Caps Lock and end up typing upper-case characters when you didn't want to? Often enough certainly that most modern password prompts now warn you that you've got Caps Lock turned on.
This is why I chose to give Caps Lock a more useful purpose. By having it act as mod key, accidentally pressing it alone will have no effect. However, it's large and reachable enough that you'll be able to use it comfortably for complex key bindings.
2 Will Window Managers Set the Mod Key to Caps Lock?
I know of a few of them which will make this hard – if at all possible. They will only allow you to set common keys such as Alt or Ctrl as the mod key, but Caps Lock appears to be a little too exotic. Take for instance the example of Notion. To set the mod key to the Windows key, you'd write:
META="Mod4+"
Looking at the source code related to mod keys, it would have seemed natural to set META
to "Lock+"
:
static const uint modmasks[N_MODS]={
ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask,
Mod4Mask, Mod5Mask
};
Unfortunately, doing so will not work, and Caps Lock will keep its initial unhelpful behaviour of entering capitals. The workaround would then be to set the mod key e.g. to the Windows key instead, and map that Windows key to Caps Lock. Two commands can achieve this: xmodmap
and setxkbmap
.
3 Old Systems
Old systems can make this work with the xmodmap
command. It's a case of removing Caps Lock's primary role, clearing mod4
and setting it to Caps Lock:
xmodmap -e "remove Lock = Caps_Lock"
xmodmap -e "clear mod4"
xmodmap -e "add Mod4 = Caps_Lock"
Something to add e.g. to your ~/.xinitrc
, then.
4 New Systems
For some reasons, xmodmap
appears not to work on more modern systems. Ubuntu Natty seems to be suffering from this, for instance. Luckily, setxkbmap
can do the business. It's in fact even easier to use, and this one-liner will do what you need:
setxkbmap -option caps:super