mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix: no need to wait on start
This commit is contained in:
parent
9e13161385
commit
211b1c2785
@ -39,7 +39,7 @@ class Network : public ALabel {
|
||||
void parseFreq(struct nlattr**);
|
||||
bool associatedOrJoined(struct nlattr**);
|
||||
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;
|
||||
void checkNewInterface(struct ifinfomsg* rtif);
|
||||
const std::string getNetworkState() const;
|
||||
|
@ -102,7 +102,7 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf
|
||||
|
||||
createEventSocket();
|
||||
createInfoSocket();
|
||||
auto default_iface = getPreferredIface();
|
||||
auto default_iface = getPreferredIface(-1, false);
|
||||
if (default_iface != -1) {
|
||||
ifid_ = default_iface;
|
||||
char ifname[IF_NAMESIZE];
|
||||
@ -515,7 +515,7 @@ bool waybar::modules::Network::checkInterface(struct ifinfomsg *rtif, std::strin
|
||||
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;
|
||||
if (config_["interface"].isString()) {
|
||||
ifid = if_nametoindex(config_["interface"].asCString());
|
||||
@ -547,8 +547,10 @@ int waybar::modules::Network::getPreferredIface(int skip_idx) const {
|
||||
if (ifid > 0) {
|
||||
return ifid;
|
||||
}
|
||||
if (wait) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user