battery: Prioritize full-at over state (#2019)

* Prioritize battery full-at over state

The `full-at` option should take priority 
over the charging state of the battery.

Closes #1622 (issue for Thinkpad laptops)

* Remove typo from clamp_percentage
This commit is contained in:
Richard 2020-06-09 21:15:36 +02:00 committed by GitHub
parent b0e9e3ff61
commit be64da3bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -286,12 +286,12 @@ namespace modules {
* Get the current battery state * Get the current battery state
*/ */
battery_module::state battery_module::current_state() { battery_module::state battery_module::current_state() {
if (!read(*m_state_reader)) { if (read(*m_capacity_reader) >= m_fullat) {
return battery_module::state::DISCHARGING;
} else if (read(*m_capacity_reader) < m_fullat) {
return battery_module::state::CHARGING;
} else {
return battery_module::state::FULL; return battery_module::state::FULL;
} else if (!read(*m_state_reader)) {
return battery_module::state::DISCHARGING;
} else {
return battery_module::state::CHARGING;
} }
} }