Skip to content

Commit

Permalink
Merge pull request #3637 from TripleTrable/backlight/add_min_brightness
Browse files Browse the repository at this point in the history
#2275  Backlight: Add minimum brightness
  • Loading branch information
Alexays authored Sep 30, 2024
2 parents 281911c + d684a6d commit e7b2d33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions man/waybar-backlight.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ The *backlight* module displays the current backlight level.
default: 1.0 ++
The speed at which to change the brightness when scrolling.

*min-brightness*: ++
typeof: double ++
default: 0.0 ++
The minimum brightness of the backlight.

*menu*: ++
typeof: string ++
Action that popups the menu.
Expand Down
8 changes: 8 additions & 0 deletions src/modules/backlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ bool waybar::modules::Backlight::handleScroll(GdkEventScroll *e) {
step = config_["scroll-step"].asDouble();
}

double min_brightness = 0;
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;
Expand Down

0 comments on commit e7b2d33

Please sign in to comment.