[RESPONDED] Controlling the keyboard backlight through /sys

Hi, I was looking into setting the keyboard backlight brightness automatically with brightnessctl but it doesn’t look like the LED is recognized by Linux. The arch wiki page on the subject says the LED should be available under /sys/class/leds, but I can only see the *lock keys LEDs, this is what I get:

/sys/class/leds/input1::capslock
/sys/class/leds/input1::numlock
/sys/class/leds/input1::scrolllock
/sys/class/leds/phy0-led

I’m not sure what phy0-led is, but I tried setting it on and off and it doesn’t affect the keyboard backlights.

Is there some kernel setting I can turn on to get the keyboard backlight to show up on /sys or is it not implemented?

1 Like

The question I have to ask is this - this is under Arch or Ubuntu, Fedora, or?

Right now, the keyboard backlight is handled entirely by the embedded controller. It’s not accessible via sysfs, since there is no driver that enumerates LEDs hanging off the EC.

I’ve been (slowly :frowning_face:) working on a driver that exposes the backlight via the LED subsystem and the charge limit via a battery hook. While it works, it’s not really “production-quality” and not ready to be submitted upstream to the kernel.

10 Likes

@DHowett is this something that you could make public while still working on it?

@DHowett Any chance you could share your general approach even if you can’t share your code? I’m trying to do something similar by modifying a Chromebook keyboard brightness kernel driver, but I think I might be barking up the wrong tree.

I would be very interested in the driver too. @DHowett can you share it?

Hey there! I’ve published the WIP source for this driver at:

YMMV, no warranty, may break, etc. Has been tested from 5.10 to 6.6.

As of right now, it exposes the keyboard backlight (read/write) and the battery charge limit (read/write).

$ cat /sys/class/leds/framework_laptop::kbd_backlight/brightness
20
$ cat /sys/class/power_supply/BAT1/charge_control_end_threshold
100
$ echo 80 | sudo tee /sys/class/power_supply/BAT1/charge_control_end_threshold
80

I have work staged that will add multicolor LED classdev support for the left/right side lights and the power button light; however, the left/right side lights are not individually controllable on the AMD models, and the power light on the Framework Chromebook doesn’t support colors. I’ve yet to deal with any of that stuff. :slight_smile:

11 Likes

Wow this stuff should be pinned somewhere and folks at FW should definitely consider doing something like this and maintain it

Thanks for this @DHowett , gonna give it a try!

Thanks @DHowett :slight_smile:

1 Like

Hmm ok forget what I said :smiley:
I see I have to compile my own kernel (since I have the 7840u) :frowning:

Any chance this module will be upstreamed, eventually? :slight_smile:

2 Likes

Hello @DHowett , is there any chance that we can see something up streamed?

I would love to be able to change keyboard backlight and battery charge limit(s).

Thanks so much for you efforts! :pray::blush:

1 Like