fix(Network): less updates

This commit is contained in:
Alex 2019-05-18 12:27:10 +02:00
parent 43d724ebad
commit d34c3a801c

View File

@ -25,7 +25,6 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf
ifname_ = ifname; ifname_ = ifname;
getInterfaceAddress(); getInterfaceAddress();
} }
dp.emit();
worker(); worker();
} }
@ -461,14 +460,12 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {
net->linked_ = true; net->linked_ = true;
net->ifname_ = ifname; net->ifname_ = ifname;
net->ifid_ = rtif->ifi_index; net->ifid_ = rtif->ifi_index;
net->dp.emit();
} }
// Check for valid interface // Check for valid interface
if (rtif->ifi_index == static_cast<int>(net->ifid_)) { if (rtif->ifi_index == static_cast<int>(net->ifid_)) {
// Get Iface and WIFI info // Get Iface and WIFI info
net->thread_timer_.wake_up();
net->getInterfaceAddress(); net->getInterfaceAddress();
net->dp.emit(); net->thread_timer_.wake_up();
} }
} else if (nh->nlmsg_type == RTM_DELADDR) { } else if (nh->nlmsg_type == RTM_DELADDR) {
auto rtif = static_cast<struct ifinfomsg *>(NLMSG_DATA(nh)); auto rtif = static_cast<struct ifinfomsg *>(NLMSG_DATA(nh));
@ -499,10 +496,11 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {
// Check for a new interface and get info // Check for a new interface and get info
auto new_iface = net->getPreferredIface(); auto new_iface = net->getPreferredIface();
if (new_iface != -1) { if (new_iface != -1) {
net->thread_timer_.wake_up();
net->getInterfaceAddress(); net->getInterfaceAddress();
net->thread_timer_.wake_up();
} else {
net->dp.emit();
} }
net->dp.emit();
} }
} }
return NL_SKIP; return NL_SKIP;