From 11533ecf0a5b78171a95bce304cd9f905b4d7ff6 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Fri, 26 Dec 2025 17:16:50 -0600 Subject: [PATCH 1/2] Add '-' support to wifi config Most modules support config fields like "format--", 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. --- src/modules/network.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index d0b7970c..951b099e 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -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) { From 2ac1f1c437456b6cdc39e76be661d7ac1c88eb56 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 3 Jul 2026 23:51:10 +0200 Subject: [PATCH 2/2] Fix clang-format --- src/modules/network.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index e7cdfcaf..0981d571 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -322,8 +322,7 @@ auto waybar::modules::Network::update() -> void { if (!state_.empty() && label_.get_style_context()->has_class(state_)) { label_.get_style_context()->remove_class(state_); } - if (!threshold_state.empty() && - config_["format-" + state + "-" + threshold_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();