I have my Caps Lock key remapped to Esc, so now I have a LED on my keyboard that is never on. I'd like to use it for something useful, like HDD or LAN activity.

Especially that I'm using a computer with a custom box & heatsinks (built into my drawer so I don't have to listen to the HDD and it doesn't take up much space), and the LEDs are not visible otherwise.

If there's a library for controlling the keyboard LEDs, I could do some coding myself, if there isn't a solution for this already.

I'm on Gentoo ~amd64.

EDIT: Ok, forget about the HDD LED. It was just an example.

I want the Caps Lock LED to light up when it's my birthday. Or when I have email. Or when I say "Caps Lock LED, please light up!".

I absolutely do not want to use an extra wire. In fact, it would be nice if this would work on wireless keyboards as well.

  • 4
    I like this idea! Hopefully someone can answer for Windows also?
    – Iszi
    Nov 29, 2011 at 18:30
  • 1
    You can edit the HDD LED requirement back to your question. The solutions might not blink as fast as normal hdd led, but it works quite nicely on my keyboard. And it's quite useful, because I can't see my hdd leds.
    – Manwe
    Jan 20, 2012 at 15:57

9 Answers 9


Well to change the led indicator on VT console you can use setleds. So if you're in a VT you can just type


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.


# Check interval seconds

# console

#indicator to use [caps, num, scroll]

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
while [ 1 ] ; do
  sleep $CHECKINTERVAL # slowdown a bit
  # get status 
  #compare state
  if [ "$NEW" = "$OLD" ]; then  
    led_off ## no change, led off
    led_on  ## change, led on
  • 1
    Thank you for this nice answer, this solution works perfectly for me, and is a good example that I can easily change to whatever I need. A already have sys-apps/kbd installed, so it worked out of the box. You deserve all the bounty I could give :)
    – Attila O.
    Jan 20, 2012 at 17:54

check Gmail - blinks LEDs when e-mails received and says the number of emails

echo "Checking for new email";
mails="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
   https://name1:password1@mail.google.com/mail/feed/atom \
   --no-check-certificate | grep 'fullcount' \
   | sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"

echo $mails;

#blink LEDs
if [ "$mails" -gt "0" ];
    blink -s -r 5;

#speak announcements

if [ "$mails" -gt "0" ];
    espeak "$mails new emails in main account.";

sleep 4;

#turn on
xset led named "Scroll Lock"

#turn off
xset -led named "Scroll Lock

also works with Caps Lock, etc.

  • 1
    This only works for Scroll Lock for me.
    – lilydjwg
    Nov 7, 2014 at 12:33

You could remove an HDD led from an old case, extend the wires and tie-wrap the wires to the keyboard wire, branch at the case, and plug direct into the HDD led jumper on the mainboard. Open the keyboard and hot-glue the HDD LED next to the capslock LED.

Software free and ugly? Check.

  • Not a bad idea altogether, but 1. I could just use the keyboard led, I don't think I need another led from an old case, and 2. I want there to be only one USB cable connecting my keyboard. Or better yet - think wireless keyboard.
    – Attila O.
    Nov 29, 2011 at 20:04

This is not a software problem to solve with a library.

The keyboard LEDs are controlled by software — in particular by the keyboard device driver generating commands to be sent to the keyboard microprocessor that turn the LEDs on and off, in response to I/O Control requests.

The hard disc activity lights on your front panel are controlled by hardware. They are connected to the mainboard, and — to cut a long story short — wired up to an output of the PCI-to-ATA bridge chip. (For the ICH10, for example, this output is the SATALED# output.) Hardware turns this output on and off as commands are sent across the SATA/PATA bus. Those who remember life with SCSI will remember that SCSI hard disc activity didn't affect the "hard disc" LED, since it is driven by the ATA bridge hardware.

It's not really practical — and would require a considerable amount of extra software and hardware — for output on the SATALED# signal to cause hardware interrupts that are received by software, which then triggers commands by the keyboard device driver. It's a fairly knuckleheaded design. But the converse approach, of having all disc I/O commands generated by the disc device driver make a side trip through the keyboard device driver is almost as bad, albeit that it doesn't require a whole new type of hardware device that receives "The front panel LED is on!" interrupts. It requires two distinct hardware subsystems — disc and keyboard — to be linked, and a fair amount of systems programming. It would also effectively limit all disc I/O to the speed of the keyboard.

This is a hardware problem to solve, very simply, with a longer piece of wire.

If your front panel is hidden away in a drawer or under a table, and you want to see the front panel LEDs, then simply make a detachable front panel of your own and connect it to the mainboard with longer wires. A quick check on eBay reveals that there exist computer component vendors that will sell to you such front panel cables (with the LEDs and switches attached) of varying lengths, up to at least 1 metre.

  • 2
    The HDD LED was just an example. The main idea is that I have at unused LED on my keyboard that I'd like to control. Please look at my edits.
    – Attila O.
    Nov 29, 2011 at 20:05

You can do that using AutoHotkey. Check this thread if you want to learn about the codes you need to use.

After reading that thread and the documentation on AutoHotkey you can do those things.

Also it works with USB and Wireless keyboards too.

You can use it with Wine on Gentoo.

  • 2
    While I was able to run AutoHotkey with Wine, for some reason it did not light up my LEDs (though no error messages were logged). Also, even if it would work, having to pipe through wine every couple of milliseconds, or having a wine process running all the time is not very optimal, especially compared to the other solution that uses setleds. Still, this might be a solution for windoze users, so thanks for posting.
    – Attila O.
    Jan 20, 2012 at 17:57


That will make the HDD LED on Scroll Lock. Modification for CAPS LOCK should be simple.


Since Linux 4.7:

# echo ide-disk > /sys/class/leds/input17::capslock/trigger

It requires CONFIG_LEDS_TRIGGER_DISK=y in the kernel config.

  • This is by far the most elegant answer and I hope it'll rise to the top!
    – mpy
    Jul 26, 2017 at 19:15
  • This works really well, but the downside is that this can stop working when unplugging and plugging the keyboard back in. Jan 6, 2018 at 3:30

I once wrote a small C program to control the CapsLock LED on my DELL XPS15. It is only tested on one System, therefore I can not guarantee that it will work for you. Maybe you would have to adapt it, but that should be pretty straight forward.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.