Xorg un-capslock

I have CapsLock mapped to Control, but sometimes CapsLock turns on anyway. But with CapsLock mapped to Control, I can’t turn it off.

How can I turn CapsLock off from a script or from the command line?

It turns out this is not super straightforward. I was hoping for a single command, but it ended up being a little more involved. Here’s a short Python script that turns off CapsLock when executed. I have it saved as uncapslock.py, very creative.

#!/usr/bin/env python

from ctypes import *

class Display(Structure):
    """ opaque struct """

X11 = cdll.LoadLibrary("libX11.so.6")
X11.XOpenDisplay.restype = POINTER(Display)

display = X11.XOpenDisplay(c_int(0))
X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
X11.XCloseDisplay(display)

LeoSearch

Started working on “LeoSearch”. It’s a tiny search engine I made for searching my bookmarks.

I inserted everything into a ClickHouse table, and implemented an inverted index and Okapi BM25 ranking. It’s pretty fast, and I’m happy with the results.