Western Digital Mybook Workd Edition has ten leds on the front side. This article talk about using it.
(Articolo solo in lingua inglese. Se qualcuno è interessato me lo faccia sapere che lo traduco in italiano.)
Leds are placed in two “rings”, outer and inner. Outer ring use four leds, and kernel uses it to shows general activity, with effect like a rotating lamp (clockwise), and can be used to notify some special conditions. Inner ring uses six leds, and can be used as a “fuel gauge”. I.e. it can be lit progressively like an empty/full indicator.
To lit it, we use a special file in /sys directory, available only when kernel module wdc-leds is loaded (should be loaded at system boot if you use my root filesystem).
File is: /sys/devices/platform/wdc-leds/leds:wdc-leds:fuel-gauge/brightness and accept a value from 0 to 255. To write a value in it we use the command:
# echo 50 > "/sys/devices/platform/wdc-leds/leds:wdc-leds:fuel-gauge/brightness"
This will lit three leds of the inner ring (at 5, 7 and 9 o’clock).
Equivalence between value and leds is:
- value from 0 to 32: lits one led (5 o’clock)
- value from 33 to 49: lits two leds (5 and 7 o’clock)
- value from 50 to 66: lits three leds (5, 7 and 9 o’clock)
- value from 67 to 82: lits four leds (5, 7, 9 and 11 o’clock)
- value from 83 to 96: lits five leds (5, 7, 9, 11 and 1 o’clock)
- value from 97 and upper: lits all leds.

In this picture you can see how leds are lit.
There is no value to put off all leds, even with 0 the first led lits (only unloading module).
Known that is really simple to arrange a “space meter” using leds, or a visual progress bar.


#1 da Lex il 7 November 2007 - 00:16
Simple disk space indicator:
(add to crontab)
*/10 * * * * root echo “0.0000002035*`df /data | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $3 }’`/1″ | bc > /sys/devices/platform/wdc-leds/leds:wdc-leds:fuel-gauge/brightness
#2 da Lex il 7 November 2007 - 00:58
Better version:
echo “`df /data | grep -vE “^Filesystem” | awk ‘{ print (81/$2)*$3+16 }’`/1″ | bc > /sys/devices/platform/wdc-leds/leds:wdc-leds:fuel-gauge/brightness
#3 da SpeedCore il 24 November 2007 - 14:23
hey there,
that space indicators won’t work fpr me, because there is no bc on my box. could you explain that awk command?
thanks,
speedcore
#4 da Lex il 26 November 2007 - 13:17
You could install bc (`apt-get install bc` or from source if you are using the original firmware)