Horizontally Scaling Keyboard LEDs

At some point in the past, a very cheap USB keyboard died on me (spacebar malfunction IIRC), so I disassembled it to re-use the two USB ports which were built-in to use them as a kind of USB extension cord to my desk. However, one of the PCBs with the ports also controlled the three keyboard LEDs.

Now, wouldn't it be nice if I could re-use those LEDs for something else than redundantly showing me Num, Caps Lock and Scroll Lock from the main keyboard?

After some research...

In /etc/X11/xorg.conf, I disabled input device hot-plug, so every input device now has a constant ID:

Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
	InputDevice    "Keyboard1" "BlinkenLights"


Section "InputDevice"
    Identifier     "Keyboard1"
    Driver         "evdev"
    Option         "Device" "/dev/input/by-id/usb-04f3_0103-event-kbd"
    Option         "XkbLayout" "drahflow"
    Option         "XkbVariant" "dvorakprog"
    Option         "XkbModel" "pc105"

Section "ServerFlags"
	Option         "AutoAddDevices" "false"
	Option         "AllowEmptyInput" "false"

And via .initrc, I set specific keycodes for that one "keyboard":

setxkbmap -device 8 -keycodes miscleds

... where miscleds refers to /usr/share/X11/xkb/keycodes/miscleds:

xkb_keycodes "miscleds" {
    minimum = 8;
    maximum = 255;

    <TLDE> = 49;

    indicator 1  = "Misc";
    indicator 2  = "Mail";
    indicator 3  = "Charging";

And a small shell-script to use the ex-keyboard, now display device, which I use to signal completion of long-running background tasks:


on() {
  xset led named 'Mail'
  xset led named 'Misc'
  xset led named 'Charging'

off() {
  xset -led named 'Mail'
  xset -led named 'Misc'
  xset -led named 'Charging'

sleep 0.05
sleep 0.05
sleep 0.05