Is there a way to use Caps/Numlock led for HD activities?

5

My laptop has not a hd activity led indicator. So, how could I use some other led (such as my keyboard NumLock or Capslock one) to blink when hd has some activity?

Thanks in advance!

OS: Linux Ubuntu 16.04 Toshiba Satellite 4k

sdlins

Posted 2017-07-24T04:30:17.383

Reputation: 153

Question was closed 2017-08-06T12:24:47.223

4

"Possible"? Yes, it's certainly possible, but you'd need to be a developer. I don't know of any software you could just install to do this. However, if you just want some indicator, you might look at the System Load Indicator as an alternative to hijacking your keyboard lights.

– phyrfox – 2017-07-24T05:21:37.580

@phyrfox you should post this as an answer... – xenoid – 2017-07-24T07:03:39.060

@phyrfox Please post your comment as an answer, i think your reply is sufficiently for the question. – None – 2017-07-24T08:13:55.260

Please check https://superuser.com/a/1158145/195224; it seems that the linux kernel >4.7 has this functionality already built in! (Not tested, yet.)

– mpy – 2017-07-25T21:32:15.277

Answers

6

It has always been possible.

The keyboard LEDs are controlled by software — 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. For comparison, the hard disc activity lights on your front panel are controlled by motherboard hardware.

From the earliest DOS days when the TV series Knight Rider and Star War's Darth Vader were popular there have been programs that controlled the keyboard lights; the most popular would make all the keyboard lights ripple in sequence.

The keyboard driver can be accessed in DOS/Win/Linux. One example for VB is here...

https://support.microsoft.com/en-us/help/177674/how-to-toggle-the-num-lock--caps-lock--and-scroll-lock-keys

as mentioned but not elaborated above, someone provided several solutions including a Bash script to do what you want at

Use Caps Lock LED as HDD LED (or custom) indicator

The simplest solution I found is a single line bash command that could be set as a cron job (perhaps every 500ms).

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

To use this requires CONFIG_LEDS_TRIGGER_DISK=y to bet set in the kernel config.

jwzumwalt

Posted 2017-07-24T04:30:17.383

Reputation: 268

1+1 for mentioning Knight Rider :) – mpy – 2017-07-26T15:51:45.237

Thanks :) .... It's embarrassing that I can even remember those lights on the car hood! – jwzumwalt – 2017-07-26T21:45:44.317

That "Use Caps Lock LED as HDD LED..." link is perfect. setleds +scroll < /dev/console or caps, or (bugged) num. Edit: And now I'm using it for scroll lock HDD activity. – Tim G – 2017-07-26T23:46:42.783

Doing this in Bash isn't computationally free, I'm seeing. It's not anywhere near impacting my system, but someone linked to some C code on that same answer that may be a better option when I have some time to review it. – Tim G – 2017-07-27T00:11:48.710

You made a great point that I did not mention. Unless there is a specific reason to use the CapsLock led (such as it's location), it would be better to preserve CapsLock and use one of the others such as ScrollLock which is an artifact from the text console days. – jwzumwalt – 2017-07-27T13:51:41.950

How do you actually set CONFIG_LEDS_TRIGGER_DISK=y in the kernel config? – user230910 – 2019-03-24T23:58:33.440

5

The easiest way to get a useful display of hard drive activity would be to install the System Load Indicator, which displays interesting statistics like CPU and RAM usage, as well as hard drive activity. This is an on-screen utility as opposed to modifying the keyboard's status lights, but is probably the closest thing you're going to find on Ubuntu without writing your own code.


If you were interested in trying your hand at writing your own code, however, you're free to do so. This is a benefit of using Linux. The keyboard uses a microprocessor that can be programmed via the CPU. On really old systems, the BIOS does this, and on newer systems, the OS does this, but either way, with a bit of work, you can write code that does this, too.

The general theory is that you'd want to watch for HDD activity and modify the keyboard status bits as appropriate. In that sense, if you're so inclined, it would certainly be "possible" to use the keyboard status lights as an HDD status light--if you're willing to put forth the effort needed to learn systems programming.

phyrfox

Posted 2017-07-24T04:30:17.383

Reputation: 2 424

Just to be clear, to most people "You can write your own" == "no" – Ed Griebel – 2017-07-25T18:20:44.127