upower: Support Multiple Keyboard Backlight LED Control

Upower can only set one keyboard backlight LED brightness. It finds the first keyboard backlight LED sysfs entry and then set up the DBus API entry for it. This works on most of the laptops but can’t work on some gaming laptops which have more than one keyboard backlight LED needs to take care. Moreover, if a USB keyboard with backlight LED was attached to laptop, upower has to discover it and set up or remove the API entry dynamically. The previous MR [1] proposed an implementation to setup multiple brightness but it can’t add/remove the device information automatically.
The new proposed MR [2] was based on udev event which gave as the device status when user install or remove a keyboard backlight LED device. Through this way, the DBus API entry and device information can be added/removed with the the udev events like what we do for the batteries. In the mean time, a abstraction class for keyboard backlight LED was proposed so upower can support different implementation, such as Linux, FreeBSD, and more [3].

[1] https://gitlab.freedesktop.org/upower/upower/-/merge_requests/203
[2] https://gitlab.freedesktop.org/upower/upower/-/merge_requests/258
[3] https://gitlab.freedesktop.org/upower/upower/-/issues/291

The policy for connecting a low power charger in Upower

Upower determines the battery charging status according to the battery charging status now. Upower sets the on_battery status to no when connecting any kind of chargers. In other words, upower ignores the battery charging status (charging/discharging) when any charger connects to a device. The original policy is good for the most of laptops with a traditional AC power adaptor. Today, we can charge the battery through a PD charger (a type-C charger) which provides different capability of charging. Yet, this cause the problems for the devices. For example, we play the cellphone game with a 5w charger and the battery discharges to maintain the performance. In this case, upower thinks that a AC charger is online so upower can ignore the battery status. Therefore, battery continue to discharge until running out of battery. The vital gaming data may lost.

Alpine Linux folks found this issue and we tried to resolve it. Now, Upower was able to show the real status for the battery when a low power charger connect to the device. Upower determines the battery status based on the current value. Upower will set on_battery status to yes, if it finds the battery discharges (a negative current value) in any conditions. This work is waiting for Alpine Linux to test it. Once it get landed, this fix will be included in the next release of upower.

[1] https://gitlab.freedesktop.org/upower/upower/-/merge_requests/244

Logitech G510 keyboard backlight supports multicolor LED API

We made the Logitech G510 keyboard to support standard multi-color LED API to configure the keyboard backlight LED colors and brightness. The legacy sysfs property “color” was removed. We invite the user or apps that configure LED color through that property to use the new one.

The G510 owner can change the color of the keyboard backlight LED through the following command

1
2
# make LED show red.
echo "255 0 0" > /sys/class/led/g15::kbd_backlight/intensity

and change the brightness through

1
echo "100" > /sys/class/led/g15::kbd_backlight/brightness

Thank you for Hans’ review.

[1] https://lore.kernel.org/linux-input/20250131140241.586305-1-hpa@redhat.com/T/#u