From 88ac00ac6a25c7b2d59c5bba56de64d44dc97e42 Mon Sep 17 00:00:00 2001 From: tteeaa Date: Tue, 10 Feb 2026 18:23:53 +0000 Subject: [PATCH] fix(custom): enforce min restart-interval to prevent UI starvation --- src/modules/custom.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index 0a8d9cf6d..59075120a 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -91,10 +91,18 @@ void waybar::modules::Custom::continuousWorker() { } if (config_["restart-interval"].isNumeric()) { pid_ = -1; - thread_.sleep_for(std::chrono::milliseconds( - std::max(1L, // Minimum 1ms due to millisecond precision - static_cast(config_["restart-interval"].asDouble() * 1000)))); + + long interval_ms = static_cast(config_["restart-interval"].asDouble() * 1000); + + // Minimum interval (1 second) to prevent UI starvation from tight loops + if (interval_ms < 1000) { + spdlog::warn("Custom module: restart-interval ({}ms) is too low. Enforcing 1000ms to prevent UI starvation.", interval_ms); + interval_ms = 1000; + } + thread_.sleep_for(std::chrono::milliseconds(interval_ms)); + fp_ = util::command::open(cmd, pid_, output_name_); + if (!fp_) { throw std::runtime_error("Unable to open " + cmd); }