Tu peux utiliser le framework “leds” directement intégré à Linux, et configurer un trigger adéquat si il existe.
https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/common.txt
https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/leds-gpio.txt
Par exemple, sur une “led” enregisrée dans le noyau:
cd /sys/class/leds/input2::scrolllock
-> % cat 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 usb-gadget usb-host disk-activity disk-read disk-write ide-disk mtd nand-disk cpu cpu0 cpu1 cpu2 cpu3 panic audio-mute audio-micmute r8169-300:00:link r8169-300:00:1Gbps r8169-300:00:100Mbps r8169-300:00:10Mbps
-> % cat 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 usb-gadget usb-host disk-activity disk-read disk-write ide-disk mtd nand-disk cpu cpu0 cpu1 cpu2 cpu3 panic audio-mute audio-micmute r8169-300:00:link r8169-300:00:1Gbps r8169-300:00:100Mbps r8169-300:00:10Mbps
-> % echo r8169-300:00:link | sudo tee trigger
r8169-300:00:link