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 use a HHKB that has the Ctrl key where Caps Lock usually is. When I need Caps Lock, I set left shift + right shift combo to Caps Lock.
@metalfabs @simontatham OP's caps lock ... lock scenario happens to me while using my HHKB but infrequently enough that I yank its USB, plug it back in and carry on.