Merge pull request #4722 from ALSchwalm/wifi-state

Add '-<state>' support to wifi config
This commit is contained in:
Alexis Rouillard
2026-07-04 00:03:33 +02:00
committed by GitHub
+9 -3
View File
@@ -315,19 +315,26 @@ auto waybar::modules::Network::update() -> void {
elapsed_seconds = std::chrono::duration<double>(interval_).count();
}
auto threshold_state = getState(signal_strength_);
if (!alt_) {
auto state = getNetworkState();
if (!state_.empty() && label_.get_style_context()->has_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();
} else if (config_["format"].isString()) {
default_format_ = config_["format"].asString();
} else {
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();
}
if (!label_.get_style_context()->has_class(state)) {
@@ -336,7 +343,6 @@ auto waybar::modules::Network::update() -> void {
format_ = default_format_;
state_ = state;
}
getState(signal_strength_);
std::string final_ipaddr_;
if (addr_pref_ == ip_addr_pref::IPV4) {