I never use Caps Lock, so I disable the Caps Lock key completely with xmodmap, to avoid hitting it by accident.
Occasionally my X server gets into caps-lock state anyway. (Usually some complicated stunt was involved, like attaching x11vnc to the display remotely.) And then I can't turn it off again using the Caps Lock key.
So I wrote a tiny X client that lets me type 'xcapslock off' at a shell prompt …
… and then I had to make an alias to it, called 'XCAPSLOCK OFF'.
@simontatham I modified my keymap so that I have to press shift+capslock (or shift+numlock) to lock/unlock them. So, no accidental triggering anymore, but I can still use it if I really want to
@pulkomandy neat – I don't know how to do that, on any OS. On X11 (which I know best) I'm 75% sure there's no way to do it with plain xmodmap, but maybe the richer XInput API has a way?
@simontatham I have this for numlock but I'm not entirely sure of what it does:
xmodmap -e 'keycode 77 = NoSymbol Num_Lock'
I didn't try caps lock yet, does it not have a keycode, or would it just be confused about shift?
@pulkomandy aha, nice! Generally 'keycode K = a b c d' means that K generates symbol a unshifted, b shifted, and I think c with AltGr and d with both modifiers.
xmodmap -e 'keycode 66 = NoSymbol Caps_Lock' is the Caps Lock equivalent of your Num Lock line. So I was wrong (or perhaps '25% wrong' :-). You _can_ do it with plain xmodmap.
@simontatham @pulkomandy the Japanese keymap has that by default (without Shift it's part of Japanese IME, with Shift it's CapsLock), so that would be a good starting point to see how it's done in different systems.