Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I get the status of a process by using the HDD and Power LEDs as indicators?

I'd like to use the green power LED to tell me that a status is available, and the red LED to tell me that it isn't.

share|improve this question

On a linux box, you can see and affect the state & brightness of various LED's through the /sys/class/leds subdirectories.

On my system:

> ls -l /sys/class/leds/
lrwxrwxrwx 1 root root 0 Jul 12 19:36 ath5k-phy0::rx -> ../../devices/pci0000:00/0000:00:14.0/0000:07:00.0/leds/ath5k-phy0::rx/
lrwxrwxrwx 1 root root 0 Jul 12 19:36 ath5k-phy0::tx -> ../../devices/pci0000:00/0000:00:14.0/0000:07:00.0/leds/ath5k-phy0::tx/

Let's look in the ath5k-phy0::rx subdir:

> ls -l
drwxr-xr-x 2 root root     0 Jul 12 21:26 power/
-rw-r--r-- 1 root root 4,096 Jul 12 21:26 brightness
lrwxrwxrwx 1 root root     0 Jul 12 21:26 device -> ../../../0000:07:00.0/
-r--r--r-- 1 root root 4,096 Jul 12 21:26 max_brightness
lrwxrwxrwx 1 root root     0 Jul 12 19:36 subsystem -> ../../../../../../class/leds/
-rw-r--r-- 1 root root 4,096 Jul 12 21:26 trigger
-rw-r--r-- 1 root root 4,096 Jul 12 19:36 uevent

If you examine the contents of the files shown, it gets interesting.

look in trigger, you can see what 'built-in' triggers are available, and which one is currently in use:

> cat trigger 
none ADP1-online BAT0-charging-or-full BAT0-charging BAT0-full BAT0-charging-blink-full-solid rfkill0 rfkill1 [phy0rx] phy0tx phy0assoc phy0radio rfkill2 

Find the entry with the square brackets (towards the right), it shows that this LED is being controlled at the moment by the wireless receiver status. It glows orange (on this system) when it receives a packet.

You can echo a name to this trigger file to change what controls it. Want to show when the battery is charging-or-full?

(as root!)
> echo BAT0-charging-or-full > trigger

If you set the controller to none, then YOU can output values to the brightness file to control the on/off of the LED.

Always good to refer to the kernel documentation for more information. GIYF

I've played with this in the past, but nothing real recent. What LED's are available are solely based on your hardware and kernel drivers/modules. YMMV.

share|improve this answer

HDD leds are normally tied to the hard drive controller. There isn't a way for an operating system on a PC to make it light up other than by causing some hard drive activity. Neither accessible to the OS is the power led.

What's easier is to use the keyboard LEDs for this purpose. Since you are indicating Ubuntu in your tags, you may want to look at a program called ledd ledcontrol.

share|improve this answer
can you help me in keyboard led light to some process? i use server... – Marcell Jul 12 '12 at 15:26 - and I'm sorry the name of the package is actually ledcontrol - Probably going to have to write a wrapper script to turn on the ledd when your process starts and turn it off when it finishes. – LawrenceC Jul 12 '12 at 15:32
so when my process is available the led turn on and when offline turn it off? :D – Marcell Jul 12 '12 at 15:34
ledcontrol is flexible, but unfortunately can't be "attached" to a process to automatically display status. You may need to write a wrapper script, write a cron job, use i/dnotify, or other mechanism to check on the status and refresh the LED's according to the state of process. There may be other tools that do something similar that I'm not aware of. – LawrenceC Jul 12 '12 at 15:48
i already write init script thats good for it? – Marcell Jul 12 '12 at 15:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .