# Some Useful Linux Snippets ## LED triggers The Linux kernel offers both direct access to LEDs and support for many different *triggers* that control when/how an LED should light up. You can see all available triggers for an LED by reading from its ''trigger'' file. The active trigger is indicated by brackets. $ cat /sys/class/leds/input0::capslock/trigger none kbd-scrolllock kbd-numlock [kbd-capslock] kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock disk-activity disk-read disk-write ide-disk mtd nand-disk cpu cpu0 cpu1 cpu2 cpu3 panic usb-gadget usb-host mmc0 wacom_battery_0-online AC-online BAT0-charging-or-full BAT0-charging BAT0-full BAT0-charging-blink-full-solid rfkill-any rfkill-none audio-mute audio-micmute rfkill0 phy0rx phy0tx phy0assoc phy0radio rfkill73 For some nice triggers (e.g., *heartbeat*, *timer*, *oneshot*, *usbport*) you might need to load their module first. $ modprobe ledtrig-timer $ echo "timer" > /sys/class/leds/input0::capslock/trigger Two new files appear: ''delay_on'' and ''delay_off''. Both accept values in milliseconds. $ echo 100 > /sys/class/leds/input0::capslock/delay_off $ echo 100 > /sys/class/leds/input0::capslock/delay_on See also: * [ledtrig-timer.c](https://github.com/torvalds/linux/blob/master/drivers/leds/trigger/ledtrig-timer.c) * [LED kernel documentation](https://www.kernel.org/doc/Documentation/leds/)