feat(network): add rfkill setting

This setting makes it possible to have a configuration with two
network modules where one of them displays the ethernet state
(disconnected, linked, ethernet), and the other, the wifi state
(disabled, disconnected, linked, wifi).

Otherwise the ethernet state would show up as "disabled" (instead of
"disconnected") when rfkill is active.
This commit is contained in:
peelz
2025-07-01 23:40:42 -04:00
parent 46a152abc8
commit 0e07c7ac5c
2 changed files with 12 additions and 3 deletions

View File

@ -16,6 +16,11 @@ Addressed by *network*
typeof: string ++ typeof: string ++
Use the defined interface instead of auto-detection. Accepts wildcard. Use the defined interface instead of auto-detection. Accepts wildcard.
*rfkill*: ++
typeof: bool ++
default: true ++
If enabled, the *disabled* format will be used when rfkill is blocking wlan interfaces.
*interval*: ++ *interval*: ++
typeof: integer ++ typeof: integer ++
default: 60 ++ default: 60 ++
@ -49,7 +54,7 @@ Addressed by *network*
*format-disabled*: ++ *format-disabled*: ++
typeof: string ++ typeof: string ++
This format is used when the displayed interface is disabled. This format is used when rfkill is blocking wlan interfaces.
*format-icons*: ++ *format-icons*: ++
typeof: array/object ++ typeof: array/object ++
@ -127,7 +132,7 @@ Addressed by *network*
*tooltip-format-disabled*: ++ *tooltip-format-disabled*: ++
typeof: string ++ typeof: string ++
This format is used when the displayed interface is disabled. This format is used when rfkill is blocking wlan interfaces.
*menu*: ++ *menu*: ++
typeof: string ++ typeof: string ++

View File

@ -273,7 +273,11 @@ void waybar::modules::Network::worker() {
const std::string waybar::modules::Network::getNetworkState() const { const std::string waybar::modules::Network::getNetworkState() const {
if (ifid_ == -1 || !carrier_) { if (ifid_ == -1 || !carrier_) {
#ifdef WANT_RFKILL #ifdef WANT_RFKILL
if (rfkill_.getState()) return "disabled"; bool display_rfkill = true;
if (config_["rfkill"].isBool()) {
display_rfkill = config_["rfkill"].asBool();
}
if (rfkill_.getState() && display_rfkill) return "disabled";
#endif #endif
return "disconnected"; return "disconnected";
} }