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"
Save the file and reboot the system.
After this, 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"
exit 1
;;
esacGood job, now you can turn your led on with these commands:
led on
led off
led toggle
Idea:
- Create a shortcut to execute this commands using the Scroll Lock key
I hope this helped :)