2

I need to run the command "xset led on" to turn on the keyboard backlight. Adding it to startup items only turns it on after login, however typing in my password without keyboard backlight can be tricky. I want to run the command automatically before login. I have tried adding it to /etc/rc.local, but it doesn't seem to work.

Could anyone tell me how to make it work? Thank you

1
  • if you're running anything later than Ubuntu 17 your default display manager is GDM/GDM3. You can configure gdm to run scripts before login as detailed in this answer: unix.stackexchange.com/a/746005/572419
    – hring
    May 16, 2023 at 3:53

1 Answer 1

3

You can create a custom lightdm configuration file, and set the greeter-setup-script option to the command you want to run. This is a one-liner for creating such a file:

sudo sh -c 'printf "[Seat:*]\ngreeter-setup-script=xset led on\n" >/etc/lightdm/lightdm.conf.d/50-kb-backlight.conf'

Edit:

If you don't have an updated Ubuntu 16.04, you may need to create the /etc/lightdm/lightdm.conf.d directory before running the above command:

sudo mkdir /etc/lightdm/lightdm.conf.d
3
  • Thank you for your answer. I get the following response to the command you recommended: sh: 1: cannot create /etc/lightdm/lightdm.conf.d/50-kb-backlight.conf: Directory nonexistent I'm new to linux so I dont really know what to do with it. Could you help me?
    – user578291
    Aug 5, 2016 at 18:58
  • Oh, you should have asked that question as a comment instead... Anyway, if you don't have an updated 16.04, you need to create the directory first: sudo mkdir /etc/lightdm/lightdm.conf.d Aug 5, 2016 at 19:01
  • Now it works perfectly. Thank you for helping me out!
    – user578291
    Aug 5, 2016 at 19:06

You must log in to answer this question.