Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Keyboard LEDs trayicons in C

I previously wrote a small tool for myself named keyboard-leds-trayicons, which wraps around mktrayicon to provide system tray icons that indicate the current status of Capslock and Numlock.

Well, I decided to learn some C programming and rewrite my cruddy shell scripts with their silly extra sleep 0.75 invocations. I incorporated the entirety of mktrayicon.c, and wrote new logic.

I started piecemeal: at first just adding basic fifo controls to the child processes. Then I got fancy and added Unix domain sockets. This has been a labor of love, and now it is ready to be shared. You can see the almost-product-worthy keyboard-leds-trayicons.c now. I enjoyed adding getopt and libinih support. C is such a good way to write small programs like this. I even learned how to use libxdo (which powers xdotool) so you can click the tray icons to toggle Capslock and Numlock!

Comments