mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(network): network info interval
This commit is contained in:
@ -90,6 +90,10 @@ void waybar::Client::bindInterfaces()
|
||||
};
|
||||
wl_registry_add_listener(registry, ®istry_listener, this);
|
||||
wl_display_roundtrip(wl_display);
|
||||
if (!layer_shell || !seat || !xdg_output_manager) {
|
||||
throw std::runtime_error("Failed to acquire required resources.");
|
||||
}
|
||||
wl_display_roundtrip(wl_display);
|
||||
}
|
||||
|
||||
int waybar::Client::main(int /*argc*/, char* /*argv*/[])
|
||||
|
@ -47,7 +47,7 @@ void waybar::modules::Battery::worker()
|
||||
// Trigger first values
|
||||
update();
|
||||
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 60;
|
||||
threadTimer_ = [this, interval] {
|
||||
thread_timer_ = [this, interval] {
|
||||
thread_.sleep_for(chrono::seconds(interval));
|
||||
dp.emit();
|
||||
};
|
||||
@ -58,7 +58,7 @@ void waybar::modules::Battery::worker()
|
||||
return;
|
||||
}
|
||||
// TODO: don't stop timer for now since there is some bugs :?
|
||||
// threadTimer_.stop();
|
||||
// thread_timer_.stop();
|
||||
dp.emit();
|
||||
};
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ waybar::modules::Cpu::Cpu(const Json::Value& config)
|
||||
auto waybar::modules::Cpu::update() -> void
|
||||
{
|
||||
try {
|
||||
// TODO: as creating dynamic fmt::arg arrays is buggy we have to do this
|
||||
// TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both
|
||||
auto cpu_load = getCpuLoad();
|
||||
auto [cpu_usage, tooltip] = getCpuUsage();
|
||||
label_.set_tooltip_text(tooltip);
|
||||
|
@ -34,6 +34,17 @@ waybar::modules::Network::Network(const Json::Value& config)
|
||||
// Trigger first values
|
||||
getInfo();
|
||||
update();
|
||||
worker();
|
||||
}
|
||||
|
||||
waybar::modules::Network::~Network()
|
||||
{
|
||||
close(sock_fd_);
|
||||
nl_socket_free(sk_);
|
||||
}
|
||||
|
||||
void waybar::modules::Network::worker()
|
||||
{
|
||||
thread_ = [this] {
|
||||
char buf[4096];
|
||||
uint64_t len = netlinkResponse(sock_fd_, buf, sizeof(buf),
|
||||
@ -74,12 +85,14 @@ waybar::modules::Network::Network(const Json::Value& config)
|
||||
dp.emit();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
waybar::modules::Network::~Network()
|
||||
{
|
||||
close(sock_fd_);
|
||||
nl_socket_free(sk_);
|
||||
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 60;
|
||||
thread_timer_ = [this, interval] {
|
||||
thread_.sleep_for(std::chrono::seconds(interval));
|
||||
if (ifid_ > 0) {
|
||||
getInfo();
|
||||
dp.emit();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
auto waybar::modules::Network::update() -> void
|
||||
|
Reference in New Issue
Block a user