fix(battery): adapter status

This commit is contained in:
Alexis 2018-12-24 12:17:07 +01:00
parent 755fad6bc3
commit de0ee9fcb2

View File

@ -145,15 +145,15 @@ const std::string waybar::modules::Battery::getState(uint8_t capacity) const
auto waybar::modules::Battery::update() -> void auto waybar::modules::Battery::update() -> void
{ {
auto [capacity, status] = getInfos(); auto [capacity, status] = getInfos();
if (status == "Unknown") {
status = getAdapterStatus(capacity);
}
label_.set_tooltip_text(status); label_.set_tooltip_text(status);
std::transform(status.begin(), status.end(), status.begin(), ::tolower); std::transform(status.begin(), status.end(), status.begin(), ::tolower);
auto format = format_; auto format = format_;
auto state = getState(capacity); auto state = getState(capacity);
label_.get_style_context()->remove_class(old_status_); label_.get_style_context()->remove_class(old_status_);
label_.get_style_context()->add_class(status); label_.get_style_context()->add_class(status);
if (status == "Unknown") {
status = getAdapterStatus(capacity);
}
old_status_ = status; old_status_ = status;
if (!state.empty() && config_["format-" + status + "-" + state].isString()) { if (!state.empty() && config_["format-" + status + "-" + state].isString()) {
format = config_["format-" + status + "-" + state].asString(); format = config_["format-" + status + "-" + state].asString();