How to prevent the keyboard backlight from turning on when the laptop is woken from sleep?

From this reddit post OP had opposite problem with lights always being turned off when resuming from suspend.

You can follow the same approach but change the 1 (on) to a 0 (off).

Find the folder /etc/systemd/system/sleep.target.wants/ and create kb_backlight_resume.service with these contents:

[Unit]
Description=Switch on keyboard backlight after resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target

[Service]
ExecStart=/bin/echo 0 > "/sys/devices/platform/thinkpad_acpi/leds/tpacpi::kbd_backlight/brightness"

[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

I don't have a Thinkpad and my Dell backlight keyboard has different directory structures. I'm unable to test this for your environment. You might have to manually tweak the code if the directory names above are off.

Don't forget to reboot before testing suspend / resume.


If you have a Dell that doesn't have /etc/systemd/system/sleep.target.wants/ it can be enabled. For example see:

  • How to disable sleep and configure lid power settings for Ubuntu or Red Hat Enterprise Linux 7

Try with:

sudo apt-get install pm-utils

Create a script in /usr/lib/pm-utils/sleep.d

sudo nano /usr/lib/pm-utils/sleep.d/KB_BACK_OFF.sh

Copy and paste the following:

#!/bin/sh

case "$1" in
       resume)
             xset led off
                ;;
esac

exit 0

Make executable the script:

sudo chmod a+x /usr/lib/pm-utils/sleep.d/KB_BACK_OFF.sh

If the command in the script xset led off does not work, try to replace it with the command xset -led (YOUR NUMBER) with a number from 1 to 32. Example: xset -led 3

I personally tried to run the script for another purpose on Kubuntu 18.04 and it works on system wake up.

YOU DON'T NEED TO RESTART THE SYSTEM