fix(backlight): %backlight% token appearing on the bar (#3081)
* Fix backlight initial value matching the actual brightness level The initial value is `0`. If the actual brightness is also `0` you see `%percentage%` token as text, it’s not being replaced. Since `m_brightness` is an `int` the initial value could be just `-1` since the actual brightness is never goes below zero. Thus this bug will never show up again because actual brightness on first render won’t match the “old” `m_brightness` value. See also for more detailed explanation of the bug: https://github.com/polybar/polybar/discussions/3079#discussioncomment-8169932 * Add docs --------- Co-authored-by: Viacheslav Lotsmanov <lotsmanov89@gmail.com>
This commit is contained in:
parent
0ed669f049
commit
8e04f15ed6
@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Fixed
|
||||
- `internal/backlight`: Module could display the literal `%percentage%` token if the backlight reports a value of 0 at startup ([`#3081`](https://github.com/polybar/polybar/pull/3081)) by [@unclechu](https://github.com/unclechu)
|
||||
|
||||
## [3.7.1] - 2023-11-27
|
||||
### Build
|
||||
|
@ -67,7 +67,12 @@ namespace modules {
|
||||
brightness_handle m_val;
|
||||
brightness_handle m_max;
|
||||
|
||||
int m_percentage = 0;
|
||||
/**
|
||||
* Initial value set to a negative number so that any value read from the backlight file triggers an update during
|
||||
* the first read.
|
||||
* Otherwise, tokens may not be replaced
|
||||
*/
|
||||
int m_percentage = -1;
|
||||
|
||||
chrono::duration<double> m_interval{};
|
||||
chrono::steady_clock::time_point m_lastpoll;
|
||||
|
Loading…
Reference in New Issue
Block a user