Skip to content

Instantly share code, notes, and snippets.

@florian-h05
Last active March 12, 2024 13:09
Show Gist options
  • Save florian-h05/08c1004d7af4e141afd959eee7cee20a to your computer and use it in GitHub Desktop.
Save florian-h05/08c1004d7af4e141afd959eee7cee20a to your computer and use it in GitHub Desktop.
Enable keyboard backlight before shutdown (for boot menu) and on startup (for login screen)

Keyboard Backlight for boot menu & login screen

Enable keyboard backlight for boot menu & login screen on ASUS ROG Zephyrus G14 (should also work with other laptops with some adjustments). Tested with Fedora 39 on ASUS ROG Zephyrus G14 GA402RK.

Boot Menu

To enable the keyboard backlight for the boot menu, keyboard backlight needs to be turned on on shutdown. This can be accomplished by placing a executable into /usr/lib/systemd/system-shutdown/ (see https://www.freedesktop.org/software/systemd/man/latest/systemd-halt.service.html).

You need to have root rights to perform the following actions (use sudo):

  1. Put the keyboard-backlight.shutdown script into /usr/lib/systemd/system-shutdown/.
  2. Find the brightness file:
    • ls -lah /sys/class/leds/asus::kbd_backlight
    • Copy the target of the link, it should be something starting with ../../devices/pci.
    • Replace %PATH_TO_BRIGHTNESS_FILE% with the copied link, however make sure you have an absolute path: /sys/devices/ instead of ../../devices/.
  3. Make the script executable: chmod -v +x keyboard-backlight.shutdown.
  4. Test the script (disable keyboard backlight before): ./keyboard-backlight.shutdown

Login Screen

To enable the keyboard backlight for the login screen, it needs to be turned on on boot. This can be accomplished by using /etc/rc.d/rc.local (or /etc/rc.local depending on Linux distribution) (see https://www.freedesktop.org/software/systemd/man/latest/rc-local.service.html).

  1. Copy the content of the working keyboard-backlight.shutdown script into /etc/rc.d/rc.local.
#!/bin/sh
# Sets keyboard brightness to high
echo -n "Setting keyboard backlight brighness to high..."
echo 3 > %PATH_TO_BRIGHTNESS_FILE%/brightness
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment