0

I would like to run a script to turn the keyboard backlight off on my Asus at login (this answer did not work). Before the introduction of systemd in Ubuntu 15.04, I did this through /etc/rc.local using the command (sleep 10 && echo 0 > /sys/class/leds/asus::kbd_backlight/brightness). However, under systemd, this no longer works.

I tried to follow the instructions here to create a systemd service. But that didn't work. This is the text I used:

[Unit] Description=MBWD Keyboard Backlight OFF script

[Service] Type=oneshot ExecStart=/usr/lib/systemd/scripts/keyboard_backlight.sh #RemainAfterExit=yes [Install] WantedBy=multi-user.target

To call this script:

 #!/bin/bash
 echo 0 | sudo tee /sys/class/leds/asus::kbd_backlight/brightness

I then enabled the service, started the service, and used the systemctl preset command to enable the service at startup (I think that's what it does).

After all this, the systemctl status command indicates that the service is enabled, and when I systemctl start the service it does dim the keyboard. And, on reboot, that is at startup, it may work, because the keyboard does turn off when Ubuntu starts up.

HOWEVER, once I get to my login screen and login, the keyboard light comes back on. I've tried to finesse this issue by using both sleep 20 in the script and by creating a systemd.timer unit. Neither worked.

Can anyone help???

2
  • Have you tried using the After directive of systemd to make it run after the window manager has started ? something like After=lightdm.service – aklmie Aug 30 '15 at 22:17
  • Thanks aklmie, that did not work though. I put After=lightdm.service in the [Unit] section, and no go. I appreciate the help -- any other ideas? – Rsync Aug 31 '15 at 18:22
1

I finally solved this problem by using an rc-local.service and /etc/rc.local instead of creating a separate systemd service. Here is what I did:

  1. In terminal: systemctl enable rc-local.service
  2. In /etc/rc.local I put the following:

#!/bin/sh -e (sleep 20 && echo 0 > /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/brightness) exit 0

  1. Make /etc/rc.local executable:

sudo chmod a+x /etc/rc.local

  1. To confirm, check the status of rc-local.service

systemctl status rc-local.service

It should show green and say active. That was it.

0

Surely not the best answer but you can switch from systemd to upstart by installing the package upstart-sysv.

sudo apt-get install upstart-sysv
1
  • Thanks. I'm hoping to stay in systemd given that Canonical switched to it as the default. – Rsync Aug 30 '15 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.