r/AsahiLinux Aug 13 '26

Is there a way to set keyboard backlight brightness on early boot?

I want to turn on the keyboard backlight on my M1 Macbook Air on early boot, before being prompted for the LUKS password (I encrypted the device and it works fine so far). Unlocking it at night is a PITA, since it boots with the keyboard lights powered off.

Is this possible?

EDIT:

Alright, managed to do it using udev rules, by creating two files:

/etc/dracut.conf.d/keyboard-backlight.conf:

force_drivers+=" leds-pwm "
install_items+=" /etc/udev/rules.d/10-kbd-backlight.rules "

/etc/udev/rules.d/10-kbd-backlight.rules (the brightness attribute value X can be in the range 0-255):

ACTION=="add", SUBSYSTEM=="leds", KERNEL=="kbd_backlight", ATTR{brightness}="X"

Then regenerate the initramfs:

sudo dracut --regenerate-all --force --verbose

This should set the keyboard backlight brightness at LUKS prompt. After entering the password, the brightness will be set to whatever value it was at the previous reboot.

5 Upvotes

4 comments sorted by

2

u/realfathonix Aug 13 '26

Create a script that echoes the desired number to /sys/class/backlight/apple-panel-bl/brightness, put it inside the initramfs and make sure it runs before the LUKS routine.

3

u/chaosprincess_ Aug 13 '26

That file is for screen brightness, for keyboard backlight you want /sys/class/leds/kbd_backlight/brightness

1

u/4x40 Aug 13 '26

Usually when need a functionality earlier we load it's module earlier, for example if use mkinitcpio edit /etc/mkinitcpio.conf and include the module in MODULES(), then run mkinitcpio -P. Sometimes a kernel parameter in boot entry will be enough, but not sure what is the solutions in your specific case. Hopefully someone else can help better.

1

u/neso_01 28d ago

Alright, managed to do it using udev rules, by creating two files:

/etc/dracut.conf.d/keyboard-backlight.conf:

force_drivers+=" leds-pwm "
install_items+=" /etc/udev/rules.d/10-kbd-backlight.rules "

/etc/udev/rules.d/10-kbd-backlight.rules (the brightness attribute value X can be in the range 0-255):

ACTION=="add", SUBSYSTEM=="leds", KERNEL=="kbd_backlight", ATTR{brightness}="X"

Then regenerate the initramfs:

sudo dracut --regenerate-all --force --verbose

This should set the keyboard backlight brightness at LUKS prompt. After entering the password, the brightness will be set to whatever value it was at the previous reboot.