mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix(client): catch error on update
This commit is contained in:
parent
087de4e956
commit
4cc48b3cfd
@ -184,7 +184,13 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos)
|
|||||||
if (pos == "modules-right") {
|
if (pos == "modules-right") {
|
||||||
modules_right_.emplace_back(module);
|
modules_right_.emplace_back(module);
|
||||||
}
|
}
|
||||||
module->dp.connect([module] { module->update(); });
|
module->dp.connect([module] {
|
||||||
|
try {
|
||||||
|
module->update();
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,12 @@ waybar::modules::Cpu::Cpu(const Json::Value& config)
|
|||||||
|
|
||||||
auto waybar::modules::Cpu::update() -> void
|
auto waybar::modules::Cpu::update() -> void
|
||||||
{
|
{
|
||||||
try {
|
// TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both
|
||||||
// TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both
|
auto cpu_load = getCpuLoad();
|
||||||
auto cpu_load = getCpuLoad();
|
auto [cpu_usage, tooltip] = getCpuUsage();
|
||||||
auto [cpu_usage, tooltip] = getCpuUsage();
|
label_.set_tooltip_text(tooltip);
|
||||||
label_.set_tooltip_text(tooltip);
|
label_.set_markup(fmt::format(format_,
|
||||||
label_.set_markup(fmt::format(format_,
|
fmt::arg("load", cpu_load), fmt::arg("usage", cpu_usage)));
|
||||||
fmt::arg("load", cpu_load), fmt::arg("usage", cpu_usage)));
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
std::cerr << e.what() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t waybar::modules::Cpu::getCpuLoad()
|
uint16_t waybar::modules::Cpu::getCpuLoad()
|
||||||
|
Loading…
Reference in New Issue
Block a user