fix(battery): More accurate battery state (#2556)
Fixes #2563 Closes #2363 * Get battery status before adapter. (#2363) * changelog: Move to Fixed section Co-authored-by: patrick96 <p.ziegler96@gmail.com>
This commit is contained in:
parent
e549527d3e
commit
968d9c753f
@ -201,6 +201,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
([`#1915`](https://github.com/polybar/polybar/issues/1915))
|
||||
- `internal/network`: The module now properly supports 'altnames' for
|
||||
interfaces.
|
||||
- `internal/battery`: More accurate battery state
|
||||
([`#2563`](https://github.com/polybar/polybar/issues/2563))
|
||||
- Some modules stop updating when system time moves backwards. ([`#857`](https://github.com/polybar/polybar/issues/857), [`#1932`](https://github.com/polybar/polybar/issues/1932))
|
||||
|
||||
## [3.5.7] - 2021-09-21
|
||||
|
@ -35,11 +35,11 @@ namespace modules {
|
||||
auto path_battery = string_util::replace(PATH_BATTERY, "%battery%", m_conf.get(name(), "battery", "BAT0"s)) + "/";
|
||||
|
||||
// Make state reader
|
||||
if (file_util::exists((m_fstate = path_adapter + "online"))) {
|
||||
m_state_reader = make_unique<state_reader>([=] { return file_util::contents(m_fstate).compare(0, 1, "1") == 0; });
|
||||
} else if (file_util::exists((m_fstate = path_battery + "status"))) {
|
||||
if (file_util::exists((m_fstate = path_battery + "status"))) {
|
||||
m_state_reader =
|
||||
make_unique<state_reader>([=] { return file_util::contents(m_fstate).compare(0, 8, "Charging") == 0; });
|
||||
} else if (file_util::exists((m_fstate = path_adapter + "online"))) {
|
||||
m_state_reader = make_unique<state_reader>([=] { return file_util::contents(m_fstate).compare(0, 1, "1") == 0; });
|
||||
} else {
|
||||
throw module_error("No suitable way to get current charge state");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user