Pages

Sunday 4 March 2012

Blink Thinkpad's light as a user

I want to get some feedback from my local jenkins instance, so I decided to ask Jenkins to blink my thinkpad's keyboard light.
I can control the light as root
# echo 255 > /sys/class/leds/tpacpi\:\:thinklight/brightness
# echo 0 > /sys/class/leds/tpacpi\:\:thinklight/brightness
But my Jenkins is running with a root account. This is where udev comes to play.
# udevadm info -q all -p /sys/devices/platform/thinkpad_acpi/leds/tpacpi\:\:thinklight/
P: /devices/platform/thinkpad_acpi/leds/tpacpi::thinklight
E: UDEV_LOG=3
E: DEVPATH=/devices/platform/thinkpad_acpi/leds/tpacpi::thinklight
E: SUBSYSTEM=leds
I tried to do it with the MODE keyword - FAIL:
# cat /etc/udev/rules.d/80-thinklight.rules
SUBSYSTEM=="leds", MODE="0666"
For some reason it did not set the permissions. I think some concepts are not clear enough for me.
So I went on another route, created a shell script to manipulate the permissions
$ cat /sbin/led.sh 
/bin/chmod o+w /sys/devices/platform/thinkpad_acpi/leds/tpacpi\:\:thinklight/brightness
And run it from udev:
$ cat /etc/udev/rules.d/99-thinklight.rules
SUBSYSTEM=="leds", RUN+="/bin/sh /sbin/led.sh"
Ugly, but WORKS




No comments:

Post a Comment