From f49a7a1acbe8489f37a88f5c8f7941a44bb90ac7 Mon Sep 17 00:00:00 2001 From: Anthony PERARD Date: Wed, 26 May 2021 18:51:02 +0100 Subject: [PATCH] network: Update WiFi information when available The module doesn't update the `essid_` as soon as a WiFi interface is connected, but that happens at some point later, depending on "interval" configuration. Fix that by rerunning the get WiFi information thread when the `carrier` state changes. Also, we will clear the state related to WiFi when the connection is drop to avoid stale information. --- src/modules/network.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 9e0ed395..583daaea 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -451,6 +451,18 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) { net->ifname_ = new_ifname; } if (carrier.has_value()) { + if (net->carrier_ != *carrier) { + if (*carrier) { + // Ask for WiFi information + net->thread_timer_.wake_up(); + } else { + // clear state related to WiFi connection + net->essid_.clear(); + net->signal_strength_dbm_ = 0; + net->signal_strength_ = 0; + net->frequency_ = 0; + } + } net->carrier_ = carrier.value(); } } else if (!is_del_event && net->ifid_ == -1) {