From 6dc5a73a02af12fccf8eac8494da7d91db23400b Mon Sep 17 00:00:00 2001 From: aidansunbury Date: Sat, 16 Aug 2025 15:29:59 -0700 Subject: [PATCH] initial changes --- include/ALabel.hpp | 2 +- man/waybar-custom.5.scd | 4 ++-- src/ALabel.cpp | 7 ++++--- src/modules/custom.cpp | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/ALabel.hpp b/include/ALabel.hpp index a1aae9da..92fc2e0f 100644 --- a/include/ALabel.hpp +++ b/include/ALabel.hpp @@ -21,7 +21,7 @@ class ALabel : public AModule { protected: Gtk::Label label_; std::string format_; - const std::chrono::seconds interval_; + const std::chrono::milliseconds interval_; bool alt_ = false; std::string default_format_; diff --git a/man/waybar-custom.5.scd b/man/waybar-custom.5.scd index 309fc184..5707010c 100644 --- a/man/waybar-custom.5.scd +++ b/man/waybar-custom.5.scd @@ -35,14 +35,14 @@ Addressed by *custom/* See *return-type* *interval*: ++ - typeof: integer ++ + typeof: integer or float ++ The interval (in seconds) in which the information gets polled. ++ Use *once* if you want to execute the module only on startup. ++ You can update it manually with a signal. If no *interval* or *signal* is defined, it is assumed that the out script loops itself. ++ If a *signal* is defined then the script will run once on startup and will only update with a signal. *restart-interval*: ++ - typeof: integer ++ + typeof: integer or float ++ The restart interval (in seconds). ++ Can't be used with the *interval* option, so only with continuous scripts. ++ Once the script exits, it'll be re-executed after the *restart-interval*. diff --git a/src/ALabel.cpp b/src/ALabel.cpp index 6df80e46..2262ad1f 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -18,9 +18,10 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st enable_scroll), format_(config_["format"].isString() ? config_["format"].asString() : format), interval_(config_["interval"] == "once" - ? std::chrono::seconds::max() - : std::chrono::seconds( - config_["interval"].isUInt() ? config_["interval"].asUInt() : interval)), + ? std::chrono::milliseconds::max() + : std::chrono::milliseconds( + static_cast( + (config_["interval"].isNumeric() ? config_["interval"].asDouble() : interval) * 1000))), default_format_(format_) { label_.set_name(name); if (!id.empty()) { diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index f9fd621e..0a7b7dd4 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -89,9 +89,10 @@ void waybar::modules::Custom::continuousWorker() { dp.emit(); spdlog::error("{} stopped unexpectedly, is it endless?", name_); } - if (config_["restart-interval"].isUInt()) { + if (config_["restart-interval"].isNumeric()) { pid_ = -1; - thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt())); + thread_.sleep_for(std::chrono::milliseconds( + static_cast(config_["restart-interval"].asDouble() * 1000))); fp_ = util::command::open(cmd, pid_, output_name_); if (!fp_) { throw std::runtime_error("Unable to open " + cmd);