Create a udev rule on /etc/udev/rules.d/99-scrolllock.rules with this content:
SUBSYSTEM=="leds", KERNEL=="input*::scrolllock", RUN+="/bin/chmod 777 /sys/class/leds/%k/brightness"
After, create a file on .local/bin/led (or other directory for your scripts), and put this content:
#!/bin/bash
LED_PATH="/sys/class/leds/input*::scrolllock/brightness"
case "$1" in
on)
echo 1 | tee $LED_PATH
;;
off)
echo 0 | tee $LED_PATH
;;
toggle)
current=$(cat $LED_PATH | head -n 1)
if [[ "$current" == 0 ]]; then
echo 1 | tee $LED_PATH
else
echo 0 | tee $LED_PATH
fi
;;
*)
echo "Arguments: on | off | toggle | sl_status"
exit 1
;;
esacGood job, now I recommend to reboot your system so you can turn your led on with these commands:
led on
led off
led toggle
I hope this helped :)