fix(backlight): also match the leds subsystem for keyboard backlights

The backlight module only enumerated and monitored the udev "backlight"
subsystem, so keyboard-backlight LEDs in the "leds" class (e.g.
white:kbd_backlight, platform::kbd_backlight) were never discovered and
the module fell back to the default when pointed at one.

Enumerate and monitor the "leds" subsystem in addition to "backlight".
Those LEDs expose the same brightness/max_brightness attributes, so the
read path is unchanged. Each device now records its subsystem so the
login1 SetBrightness call targets the correct one. Automatic device
selection still prefers a "backlight" device and only falls back to a
"leds" device when named explicitly or when no screen backlight exists.

Fixes #2848.
This commit is contained in:
Alex
2026-07-04 13:43:01 +02:00
parent 4c55819888
commit 8ff8ceeca2
4 changed files with 50 additions and 14 deletions
+6 -2
View File
@@ -27,9 +27,11 @@ namespace waybar::util {
class BacklightDevice {
public:
BacklightDevice() = default;
BacklightDevice(std::string name, int actual, int max, bool powered);
BacklightDevice(std::string name, int actual, int max, bool powered,
std::string subsystem = "backlight");
std::string name() const;
std::string subsystem() const;
int get_actual() const;
void set_actual(int actual);
int get_max() const;
@@ -45,6 +47,7 @@ class BacklightDevice {
int actual_ = 1;
int max_ = 1;
bool powered_ = true;
std::string subsystem_ = "backlight";
};
class BacklightBackend {
@@ -70,7 +73,8 @@ class BacklightBackend {
std::mutex udev_thread_mutex_;
private:
void set_brightness_internal(const std::string& device_name, int brightness, int max_brightness);
void set_brightness_internal(const std::string& device_name, int brightness, int max_brightness,
const std::string& subsystem = "backlight");
std::function<void()> on_updated_cb_;
std::chrono::milliseconds polling_interval_;