Backlight: Add minimum brightness

As currently it is possible to turn the brightness to zero which may not
be desirable, this patch add a configurable brightness check.
This commit is contained in:
Lars Niesen
2024-09-24 21:41:54 +02:00
parent 07f75e303c
commit 04bda9f443

View File

@ -112,6 +112,14 @@ bool waybar::modules::Backlight::handleScroll(GdkEventScroll *e) {
step = config_["scroll-step"].asDouble(); step = config_["scroll-step"].asDouble();
} }
double min_brightness = 10;
if (config_["min-brightness"].isDouble()) {
min_brightness = config_["min-brightness"].asDouble();
}
if (backend.get_scaled_brightness(preferred_device_) <= min_brightness &&
ct == util::ChangeType::Decrease) {
return true;
}
backend.set_brightness(preferred_device_, ct, step); backend.set_brightness(preferred_device_, ct, step);
return true; return true;