fix: no need to wait on start

pull/472/head
Alex 2019-09-25 09:32:22 +01:00
parent 9e13161385
commit 211b1c2785
2 changed files with 6 additions and 4 deletions

View File

@ -39,7 +39,7 @@ class Network : public ALabel {
void parseFreq(struct nlattr**); void parseFreq(struct nlattr**);
bool associatedOrJoined(struct nlattr**); bool associatedOrJoined(struct nlattr**);
bool checkInterface(struct ifinfomsg* rtif, std::string name); bool checkInterface(struct ifinfomsg* rtif, std::string name);
int getPreferredIface(int skip_idx = -1) const; int getPreferredIface(int skip_idx = -1, bool wait = true) const;
auto getInfo() -> void; auto getInfo() -> void;
void checkNewInterface(struct ifinfomsg* rtif); void checkNewInterface(struct ifinfomsg* rtif);
const std::string getNetworkState() const; const std::string getNetworkState() const;

View File

@ -102,7 +102,7 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf
createEventSocket(); createEventSocket();
createInfoSocket(); createInfoSocket();
auto default_iface = getPreferredIface(); auto default_iface = getPreferredIface(-1, false);
if (default_iface != -1) { if (default_iface != -1) {
ifid_ = default_iface; ifid_ = default_iface;
char ifname[IF_NAMESIZE]; char ifname[IF_NAMESIZE];
@ -515,7 +515,7 @@ bool waybar::modules::Network::checkInterface(struct ifinfomsg *rtif, std::strin
return false; return false;
} }
int waybar::modules::Network::getPreferredIface(int skip_idx) const { int waybar::modules::Network::getPreferredIface(int skip_idx, bool wait = true) const {
int ifid = -1; int ifid = -1;
if (config_["interface"].isString()) { if (config_["interface"].isString()) {
ifid = if_nametoindex(config_["interface"].asCString()); ifid = if_nametoindex(config_["interface"].asCString());
@ -547,8 +547,10 @@ int waybar::modules::Network::getPreferredIface(int skip_idx) const {
if (ifid > 0) { if (ifid > 0) {
return ifid; return ifid;
} }
if (wait) {
std::this_thread::sleep_for(std::chrono::milliseconds(500)); std::this_thread::sleep_for(std::chrono::milliseconds(500));
} }
}
return -1; return -1;
} }