Well to change the led indicator on VT console you can use setleds
. So if you're in a VT you can just type
setleds
and you'll get your current led status.
If you don't want to enable numlock, just light it up you can type:
setleds -L +num
It comes trickier in X and this is the "simplest" way to try it. Please note that X is usually ran as root so you'll either have to check permissions on X-windows tty or run it with root privileges. Usually X is tty7. /dev/console
should work being the system console and by that all VTs should be affected.
sudo su -c 'setleds -L +num < /dev/tty7'
I think this will also work:
sudo su -c 'setleds -L +num < /dev/console'
here's list of light options
[{+|-}num] [{+|-}caps] [{+|-}scroll]
If you don't have setleds
in you system, my guess is that you can get it from this emerge package sys-apps/kbd
.
If you are more of person who likes to code stuff here's a link to en example code to change leds in X. I did not test this, but just by looking the code looked ok.
And here's a shell script to do what you originally wanted. To have caps or other leds as HDD indicators.
#!/bin/bash
# Check interval seconds
CHECKINTERVAL=0.1
# console
CONSOLE=/dev/console
#indicator to use [caps, num, scroll]
INDICATOR=caps
getVmstat() {
cat /proc/vmstat|egrep "pgpgin|pgpgout"
}
#turn led on
function led_on()
{
setleds -L +${INDICATOR} < ${CONSOLE}
}
#turn led off
function led_off()
{
setleds -L -${INDICATOR} < ${CONSOLE}
}
# initialise variables
NEW=$(getVmstat)
OLD=$(getVmstat)
##
while [ 1 ] ; do
sleep $CHECKINTERVAL # slowdown a bit
# get status
NEW=$(getVmstat)
#compare state
if [ "$NEW" = "$OLD" ]; then
led_off ## no change, led off
else
led_on ## change, led on
fi
OLD=$NEW
done
After some investigation, I found the culprit: I had been using a custom keyboard layout that disabled dead keys, and apparently it also forced the usage of the Shift key to turn off caps-lock (ShiftLock as some call it).
I had tried switching to the default layout before and it didn't seem to work, now I realize that probably was because I had tested on an existing Notepad window instead of opening a new one.
Solution: I downloaded MSKLC and created a new layout based on that one but without enabling ShiftLock.
Best Answer
In autohotkey:
Though you could then set Capslock itself to a much more useful function rather than disabling it entirely. You could have it equal to shift, for example:
or set it to open/switch to Firefox:
(Though the latter would need a tiny bit of configuration for FF's path, and how long you need the sleep to be)