Skip to content

Instantly share code, notes, and snippets.

@synt-xerror
Last active February 17, 2026 19:42
Show Gist options
  • Select an option

  • Save synt-xerror/a76ce69fb2dcaa9237b101f045458024 to your computer and use it in GitHub Desktop.

Select an option

Save synt-xerror/a76ce69fb2dcaa9237b101f045458024 to your computer and use it in GitHub Desktop.
Script to turn keyboard led on

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
		;;
esac

Good 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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment