LED handling under Linux
In its simplest form, the LED class just allows control of LEDs from userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the LED is defined in max_brightness file. The brightness file will set the brightness of the LED (taking a value 0-max_brightness). Most LEDs don’t have hardware brightness support so will just be turned on for non-zero brightness settings.
The class also introduces the optional concept of an LED trigger. A trigger is a kernel based source of led events. Triggers can either be simple or complex. A simple trigger isn’t configurable and is designed to slot into existing subsystems with minimal additional code. Examples are the disk-activity, nand-disk and sharpsl-charge triggers. With led triggers disabled, the code optimises away.
Complex triggers while available to all LEDs have
LED specific parameters and work on a per LED
basis. The timer trigger is an example. The timer
trigger will periodically change the LED
brightness between LED_OFF and the current
brightness setting. The “on” and “off” time can be
specified via
/sys/class/leds/
You can change triggers in a similar manner to the
way an IO scheduler is chosen (via
/sys/class/leds/