Turning on Caps Lock when the Caps Lock key is bound to a different key
This post's featured URL for sharing metadata is https://www.jvt.me/img/profile.jpg.
As a Vim user, and as someone who doesn't use CapsLock very often, I've had my CapsLock key rebound to ESC for the last 7(!) years.
In the last week I've had a couple of times where my new work laptop's lost the configuration, and I've accidentally hit CapsLock which has then actually set Caps Lock instead of triggering ESC. I've generally then reset my keybindings before noticing that I've got Caps Lock turned, on, which has led to me being unable to turn it off, or even type in my terminal to unset it.
This has been a little bit embarrassing, so when it's just happened to me right now, I was very happy to find, via this AskUbuntu answer, that we can use xdotool
to trigger the event:
# Note the capitals
xdotool key Caps_Lock
This is great because it surprisingly doesn't get picked up by any rebinding, and will correctly (un)set Caps Lock.
Another clever commenter suggested something I'd rarely have considered - use the Shift key while in Caps Lock to return to normal casing.