Add '-<state>' support to wifi config
Most modules support config fields like "format-<status>-<state>", so the user can, for example, set a different format for batter when unplugged _and_ under a given level. Wifi didn't support this. Change the module to support format state based on signal strength.
This commit is contained in:
+10
-3
@@ -291,19 +291,27 @@ auto waybar::modules::Network::update() -> void {
|
||||
bandwidth_up_total_ = up_octets;
|
||||
}
|
||||
|
||||
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)) {
|
||||
@@ -312,7 +320,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) {
|
||||
|
||||
Reference in New Issue
Block a user