Programmatically Clearing Caps Lock In Linux

I'm not particularly a fan of caps lock. I typically re-map the caps lock key to do something more useful. Sometimes caps lock becomes enabled accidentally or because some application enables it to be "helpful". Here's a little python script I keep around to disable caps lock from a terminal/shell just in case.

#!/usr/bin/env python
from ctypes import *
X11 = cdll.LoadLibrary("libX11.so.6")
display = X11.XOpenDisplay(None)
X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
X11.XCloseDisplay(display)
Source

1 comment