From 698b96d17bbbed5ca37b2587827aff2377d1360d Mon Sep 17 00:00:00 2001 From: the Date: Tue, 16 Feb 2021 04:02:33 -0500 Subject: [PATCH] feat(backlight): add use-actual-brightness option (#2380) * add use-actual-brightness option * added to changelog * added to changelog 2 * added to changelog 3 --- CHANGELOG.md | 3 +++ include/modules/backlight.hpp | 1 + src/modules/backlight.cpp | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b91b88f..7eea9695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `internal/xworkspaces`: `%nwin%` can be used to display the number of open windows per workspace ([`#604`](https://github.com/polybar/polybar/issues/604)) +- `internal/backlight`: added `use-actual-brightness` option ### Changed - Slight changes to the value ranges the different ramp levels are responsible @@ -106,6 +107,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([`#2292`](https://github.com/polybar/polybar/issues/2292)) - Parser error if click command contained `}` ([`#2040`](https://github.com/polybar/polybar/issues/2040)) +- `internal/backlight`: With amdgpu backlights, the brightness indicator was slightly behind. + ([`#2367](https://github.com/polybar/polybar/issues/2367)) ## [3.5.4] - 2021-01-07 ### Fixed diff --git a/include/modules/backlight.hpp b/include/modules/backlight.hpp index 34dcfe4a..5cf66c39 100644 --- a/include/modules/backlight.hpp +++ b/include/modules/backlight.hpp @@ -48,6 +48,7 @@ namespace modules { string m_path_backlight; float m_max_brightness; bool m_scroll{false}; + bool m_use_actual_brightness{true}; brightness_handle m_val; brightness_handle m_max; diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index 353a0cc8..4119536b 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -54,7 +54,10 @@ namespace modules { * The only sensible way is to use the 'brightness' file instead * Ref: https://github.com/Alexays/Waybar/issues/335 */ - std::string brightness_type = ((card.substr(0, 9) == "amdgpu_bl") ? "brightness" : "actual_brightness"); + bool card_is_amdgpu = (card.substr(0, 9) == "amdgpu_bl"); + m_use_actual_brightness = m_conf.get(name(), "use-actual-brightness", !card_is_amdgpu); + + std::string brightness_type = (m_use_actual_brightness ? "actual_brightness" : "brightness"); auto path_backlight_val = m_path_backlight + "/" + brightness_type; m_val.filepath(path_backlight_val);