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.
This commit is contained in:
Anthony PERARD 2021-05-26 18:51:02 +01:00
parent 28dfb0ba41
commit f49a7a1acb

View File

@ -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) {