Handle screens disconnection (#29)

This commit is contained in:
Alex
2018-08-19 13:39:57 +02:00
committed by GitHub
parent ce50a627be
commit 6705134034
23 changed files with 205 additions and 133 deletions

View File

@ -29,8 +29,10 @@ waybar::modules::Network::Network(Json::Value config)
}
}
label_.set_name("network");
// Trigger first values
getInfo();
Glib::signal_idle().connect_once(sigc::mem_fun(*this, &Network::update));
update();
thread_.sig_update.connect(sigc::mem_fun(*this, &Network::update));
thread_ = [this] {
char buf[4096];
uint64_t len = netlinkResponse(sock_fd_, buf, sizeof(buf),
@ -67,11 +69,16 @@ waybar::modules::Network::Network(Json::Value config)
}
if (need_update) {
getInfo();
Glib::signal_idle().connect_once(sigc::mem_fun(*this, &Network::update));
thread_.sig_update.emit();
}
};
}
waybar::modules::Network::~Network()
{
close(sock_fd_);
}
auto waybar::modules::Network::update() -> void
{
auto format = config_["format"] ? config_["format"].asString() : "{ifname}";