Added second warning stage to battery module
Also naming is a bit more consistent
This commit is contained in:
parent
e93c5e7957
commit
4c8621c7a5
|
@ -43,6 +43,8 @@
|
||||||
"format": "{}% "
|
"format": "{}% "
|
||||||
},
|
},
|
||||||
"battery": {
|
"battery": {
|
||||||
|
// "warning": 30, // Default value: 30
|
||||||
|
// "critical": 15, // Default value: 15
|
||||||
"format": "{capacity}% {icon}",
|
"format": "{capacity}% {icon}",
|
||||||
"format-icons": ["", "", "", "", ""]
|
"format-icons": ["", "", "", "", ""]
|
||||||
},
|
},
|
||||||
|
|
|
@ -88,10 +88,16 @@ auto waybar::modules::Battery::update() -> void
|
||||||
} else {
|
} else {
|
||||||
label_.get_style_context()->remove_class("charging");
|
label_.get_style_context()->remove_class("charging");
|
||||||
}
|
}
|
||||||
|
auto warning = config_["warning"].isUInt() ? config_["warning"].asUInt() : 30;
|
||||||
auto critical = config_["critical"].isUInt() ? config_["critical"].asUInt() : 15;
|
auto critical = config_["critical"].isUInt() ? config_["critical"].asUInt() : 15;
|
||||||
if (capacity <= critical && !charging) {
|
if (capacity <= critical && !charging) {
|
||||||
|
label_.get_style_context()->add_class("critical");
|
||||||
|
label_.get_style_context()->remove_class("warning");
|
||||||
|
} else if (capacity <= warning && !charging) {
|
||||||
label_.get_style_context()->add_class("warning");
|
label_.get_style_context()->add_class("warning");
|
||||||
|
label_.get_style_context()->remove_class("critical");
|
||||||
} else {
|
} else {
|
||||||
|
label_.get_style_context()->remove_class("critical");
|
||||||
label_.get_style_context()->remove_class("warning");
|
label_.get_style_context()->remove_class("warning");
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
|
Loading…
Reference in New Issue