How to have keyboard backlights turned on at boot

Controlling keyboard backlights with the appropriate function key works well (in steps of 33%, from 0 to 100%, by pressing fn-f7).

However after a fresh startup, and logging in, the keyboard backlights are always off. Even if I had them on when turning off the laptop.

I’d like them to be turned on, preferably at 33%, when I’m logging in.

I’ve browsed the Plasma-settings, searched over at arch[1], and I’ve searched this forum.
No luck so far.

Is there a setting to get them on at boot?
Any pointers?
Might it be a bug?

system:
  Host: vivobookEOS001 Kernel: 6.6.28-1-lts arch: x86_64 bits: 64
    compiler: gcc v: 13.2.1 clocksource: tsc avail: hpet,acpi_pm
    parameters: initrd=\21b5e525d98d4033ac2933bbccc6e69c\6.6.28-1-lts\initrd
    nvme_load=YES nowatchdog rw
    root=UUID=28f050a6-a6dc-4606-8a11-bd5d9946eccc
    systemd.machine_id=21b5e525d98d4033ac2933bbccc6e69c
  Desktop: KDE Plasma v: 6.0.4 tk: Qt v: N/A info: frameworks v: 6.1.0
    wm: kwin_wayland with: krunner vt: 1 dm: SDDM Distro: EndeavourOS
    base: Arch Linux
Machine:
  Type: Laptop System: ASUSTeK product: Vivobook_ASUSLaptop M1605YA_M1605YA
    v: 1.0 serial: <superuser required>
  Mobo: ASUSTeK model: M1605YA v: 1.0 serial: <superuser required>
    uuid: <superuser required> UEFI: American Megatrends LLC. v: M1605YA.302
    date: 03/02/2023
Battery:
  ID-1: BAT0 charge: 22.6 Wh (51.8%) condition: 43.6/42.1 Wh (103.7%)
    power: 4.0 W volts: 11.4 min: 11.8 model: ASUSTeK ASUS Battery type: Li-ion
    serial: N/A status: discharging cycles: 20
CPU:
  Info: 8-core AMD Ryzen 7 5825U with Radeon Graphics [MT MCP] arch: Zen 3
    speed (MHz): avg: 524 min/max: 400/4546
Graphics:
  Device-1: AMD Barcelo vendor: ASUSTeK driver: amdgpu v: kernel arch: GCN-5
    code: Vega process: GF 14nm built: 2017-20 pcie: gen: 3 speed: 8 GT/s
    lanes: 16 link-max: gen: 4 speed: 16 GT/s ports: active: eDP-1
    empty: HDMI-A-1 bus-ID: 03:00.0 chip-ID: 1002:15e7 class-ID: 0300
    temp: 30.0 C
  Device-2: ShineTech USB2.0 HD UVC WebCam driver: uvcvideo type: USB
    rev: 2.0 speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 3-3:3 chip-ID: 3277:0036
    class-ID: fe01 serial: 0x0001
  Display: wayland server: X.org v: 1.21.1.13 with: Xwayland v: 23.2.6
    compositor: kwin_wayland driver: X: loaded: amdgpu unloaded: modesetting
    alternate: fbdev,vesa dri: radeonsi gpu: amdgpu resolution: 1920x1200
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 24.0.5-arch1.1
    glx-v: 1.4 direct-render: yes renderer: AMD Radeon Graphics (radeonsi
    renoir LLVM 17.0.6 DRM 3.54 6.6.28-1-lts) device-ID: 1002:15e7
    memory: 500 MiB unified: no display-ID: :1.0
Operating System: EndeavourOS 
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0
Kernel Version: 6.6.28-1-lts (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5825U with Radeon Graphics
Memory: 15.0 GiB of RAM
Graphics Processor: AMD Radeon Graphics

https://wiki.archlinux.org/index.php?search=keyboard+backlight+asus&title=Special%3ASearch&wprov=acrw1_-1

For me, Lenvo legion 5, with not overly complcated lights:

echo 2 | sudo tee /sys/class/leds/platform::kbd_backlight/brightness

Zero = off
1 = 50%
2 = 100&

1 Like

My Lenovo Thinkbook keyboard backlight always turns on when booting then after it gets to the desktop it turns off after a minute. You have to turn it back on with the Fn space bar. Then you can also adjust the brightness with fn keys.

1 Like

Thanks! I’ll see what works for me laptop later today.

You can also use a userspace application like brightnessctl to do this.

Make sure you have it installed.

$ sudo pacman -S brightnessctl

To list all devices that brightnessctl can control, run

$ brightnessctl --list

That command should return a list of devices. Each entry in the list should have a format that looks something like this:

Device 'vendorname::devicename' of class 'backlight':
	... a list of attributes

Scroll through the list and look for the device name kbd_backlight. Take note of its vendor name as well. To know what settings/values are available, run

$ brightnessctl --device="vendorname::kbd_backlight" info

Obviously, you must substitute vendorname with the actual vendor name.

To set a value, just run

$ brightnessctl --device="vendorname::kbd_backlight" set some_value

If everything works, include the last command in your init scripts to run at boot.

2 Likes

I use an app called openrgb, and it gets the lights lit up at boot. I use it for my Phantom kb cause it doesnt have a linux driver.

I don’t use any brightness app on my Lenovo Thinkbook. When it boots the keyboards light up to show you it’s working and then go out. After it’s booted to the desktop you turn it on with Fn spacebar. That is the lowest level of brightness. Then you hit that again for the highest level of brightness and again to turn it off. If you leave it turned on then on subsequent reboots it’s stays on.

Thanks @xircon,

There is no “platform” file for my keyboard backlight.

Tried editing:

/sys/class/leds/asus\:\:kbd_backlight/brightness

setting it to ´1´ (from ‘0’).

At reboot the value was set to 0 again.

Will try some of the other suggestions.

edit: typo

Does:

echo 2 | sudo tee /sys/class/leds/asus\:\:kbd_backlight/brightness

Do anything (also try 0 & 1)?

I will write a systemd unit for you when I get home from work, if it does

Indeed; that works: it changes the value in the file.

Allowed values in my case are

0: off
1: 33%
2: 66%
3: 100%

As per @anthony93 's suggestion I ran:

brightnessctl --list
rightnessctl --device="asus::kbd_backlight" info

which gave:

Device 'asus::kbd_backlight' of class 'leds':
        Current brightness: 2 (67%)
        Max brightness: 3

I was just looking into making a systemd unit like suggested, but I have hardly any experience so any help would be helpful.

(I tried to make a unit file for getting my network shares mounted at boot [in stead of fstab entries); but that never really worked well, so I abandoned the idea.)

It is 14:32 here, will be back home about 17:30, will upload it shortly after :smiley:

I put mine in my shell config file (.zshrc) because I don’t use a sudo password (my machine, my rules) :rofl:

This isn’t difficult to do.

First, create a service file. For example, /etc/systemd/system/kbd_backlight.service

The contents of the service file should look something like this:

[Unit]
Description=Turn on keyboard backlight.

[Service]
Type=simple
ExecStart=/bin/brightnessctl

[Install]
WantedBy=multi-user.target

Remember to add the actual brightnessctl command you want to use for ExecStart; don’t just use the contents above verbatim.

Make sure to change the permission of the service file to 644:

$ sudo chmod 644 /etc/systemd/system/kbd_backlight.service

Finally, enable the service:

$ sudo systemctl enable kdb_backlight.service

Reboot and test.

If you prefer to use a GUI, I think KDE has a way for you to add login scripts.

Just write a script containing the brightnessctl command and point the GUI to the script. The downside to this approach is that the script will only be run after you log in.

My Lenovo Thinkbook keyboard backlight turns on when booting and stays on to whatever it was set to using the Fn space bar at that time and cares over on each fresh install or boot.

1 Like

I didn’t know about that part of "autostart¨. Thank you!

Thank you!

1 Create script kb-light.sh:

#!/usr/bin/env bash
echo 3 |  tee /sys/class/leds/asus::kbd_backlight/brightness

Make executable, place in /usr/bin

create /etc/systemd/system/kb-light.service (sudo nano /etc/systemd/system/kb-light.service):

[Unit]
Description=Set Keyboard light

[Service]
User=root
WorkingDirectory=/usr/bin/
ExecStart=kb-light.sh
# optional items below
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

enable sudo systemctl enable kb-light.service --now reboot to test.

My question is why? Why if these laptops come with backlit keyboards why does one have to do this. Mine automatically works on my Thinkbook as i would expect it to.

1 Like

Because mine doesn’t! and neither does @SemLraug’s…

Sorry for not getting back to you.

Life is keeping me busy and I’m not near my laptop at the moment.

Will be back later.

Thanks for helping me all.

So, the current state is:

Before @anthony93 and @xircon kindly offered their script and unit solution I had tried:

echo 2 | sudo tee /sys/class/leds/platform::kbd_backlight/brightness

That turned on the keyboard backlights, but at reboot this setting was reset to 0, hence the backlight was turned off again.

I also tried:

brightnessctl --device="vendorname::kbd_backlight" set some_value

That gave the same result: reset at reboot.

I’ll now try the unit file.

I agree with @ricklinux that this should not be necessary, but having tried everything else I think the unit file is worth the effort for me.