Merge pull request #4722 from ALSchwalm/wifi-state
Add '-<state>' support to wifi config
This commit is contained in:
@@ -315,19 +315,26 @@ auto waybar::modules::Network::update() -> void {
|
|||||||
elapsed_seconds = std::chrono::duration<double>(interval_).count();
|
elapsed_seconds = std::chrono::duration<double>(interval_).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto threshold_state = getState(signal_strength_);
|
||||||
|
|
||||||
if (!alt_) {
|
if (!alt_) {
|
||||||
auto state = getNetworkState();
|
auto state = getNetworkState();
|
||||||
if (!state_.empty() && label_.get_style_context()->has_class(state_)) {
|
if (!state_.empty() && label_.get_style_context()->has_class(state_)) {
|
||||||
label_.get_style_context()->remove_class(state_);
|
label_.get_style_context()->remove_class(state_);
|
||||||
}
|
}
|
||||||
if (config_["format-" + state].isString()) {
|
if (!threshold_state.empty() && config_["format-" + state + "-" + threshold_state].isString()) {
|
||||||
|
default_format_ = config_["format-" + state + "-" + threshold_state].asString();
|
||||||
|
} else if (config_["format-" + state].isString()) {
|
||||||
default_format_ = config_["format-" + state].asString();
|
default_format_ = config_["format-" + state].asString();
|
||||||
} else if (config_["format"].isString()) {
|
} else if (config_["format"].isString()) {
|
||||||
default_format_ = config_["format"].asString();
|
default_format_ = config_["format"].asString();
|
||||||
} else {
|
} else {
|
||||||
default_format_ = DEFAULT_FORMAT;
|
default_format_ = DEFAULT_FORMAT;
|
||||||
}
|
}
|
||||||
if (config_["tooltip-format-" + state].isString()) {
|
if (!threshold_state.empty() &&
|
||||||
|
config_["tooltip-format-" + state + "-" + threshold_state].isString()) {
|
||||||
|
tooltip_format = config_["tooltip-format-" + state + "-" + threshold_state].asString();
|
||||||
|
} else if (config_["tooltip-format-" + state].isString()) {
|
||||||
tooltip_format = config_["tooltip-format-" + state].asString();
|
tooltip_format = config_["tooltip-format-" + state].asString();
|
||||||
}
|
}
|
||||||
if (!label_.get_style_context()->has_class(state)) {
|
if (!label_.get_style_context()->has_class(state)) {
|
||||||
@@ -336,7 +343,6 @@ auto waybar::modules::Network::update() -> void {
|
|||||||
format_ = default_format_;
|
format_ = default_format_;
|
||||||
state_ = state;
|
state_ = state;
|
||||||
}
|
}
|
||||||
getState(signal_strength_);
|
|
||||||
|
|
||||||
std::string final_ipaddr_;
|
std::string final_ipaddr_;
|
||||||
if (addr_pref_ == ip_addr_pref::IPV4) {
|
if (addr_pref_ == ip_addr_pref::IPV4) {
|
||||||
|
|||||||
Reference in New Issue
Block a user