mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Add class for full battery and give option to interpret unknown as full
This commit is contained in:
parent
00e7e87f55
commit
9c57df505c
@ -74,6 +74,8 @@ std::tuple<uint16_t, std::string> waybar::modules::Battery::getInfos()
|
||||
std::ifstream(bat / "status") >> _status;
|
||||
if (_status != "Unknown") {
|
||||
status = _status;
|
||||
}else if (config_["full-is-unknown"].isString() && config_["full-is-unknown"] == "true") {
|
||||
status = "Full"; //Some notebooks (e.g. Thinkpad T430s) report a full battery as "Unknown".
|
||||
}
|
||||
total += capacity;
|
||||
}
|
||||
@ -125,9 +127,14 @@ auto waybar::modules::Battery::update() -> void
|
||||
}
|
||||
} else {
|
||||
label_.get_style_context()->remove_class("charging");
|
||||
if (status == "Full" && config_["format-full"].isString()) {
|
||||
if (status == "Full"){
|
||||
label_.get_style_context()->add_class("full");
|
||||
if (config_["format-full"].isString()) {
|
||||
format = config_["format-full"].asString();
|
||||
}
|
||||
}else{
|
||||
label_.get_style_context()->remove_class("full");
|
||||
}
|
||||
}
|
||||
auto state = getState(capacity, charging);
|
||||
if (!state.empty() && config_["format-" + state].isString()) {
|
||||
|
Loading…
Reference in New Issue
Block a user