Sunday, October 22, 2006

Keyboard LEDs

Ever made a script which runs in background, but you want it to tell you the status every now and then? Most likely, you'll resort to emailing the status to yourself. But, emailing isn't really convinient when all you wanna know is if it is on or not or something like that. Something that is far more convinient is setting the keyboard LEDs. The program which sets the keyboard LEDs is "setleds". You have an option of setting only the LEDs and not the flags (capslock, numlock etc.). However, I've not been able to find a way to actually toggle the flags when running X. Moreover, this requires you to set UID on the setleds binary (or run it as root in any other way). For example, to the set the numlock LED to on, run the following command:

# setleds -L +num < /dev/console
You can have a look at my script which gives an example of how to use this program in scripts (this script blinks the keyboard LEDs in the given sequence or randomly).

No comments: