From 04bda9f443a2ab8ac21ce3efe762bd1a907dc248 Mon Sep 17 00:00:00 2001 From: Lars Niesen Date: Tue, 24 Sep 2024 21:41:54 +0200 Subject: [PATCH] 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. --- src/modules/backlight.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index 4ae511eb..6bfe8cee 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -112,6 +112,14 @@ bool waybar::modules::Backlight::handleScroll(GdkEventScroll *e) { 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); return true;