From 2aed121903df5f2ea4274046e3c1b3a2aa9b39ce Mon Sep 17 00:00:00 2001 From: David96 Date: Sat, 24 Nov 2018 17:21:46 +0100 Subject: [PATCH] Allow custom plugins that don't execute anything --- src/modules/custom.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index 73b9d51..74ae0f2 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -4,13 +4,14 @@ waybar::modules::Custom::Custom(const std::string name, const Json::Value& config) : ALabel(config, "{}"), name_(name) { - if (!config_["exec"].isString()) { - throw std::runtime_error(name_ + " has no exec path."); - } - if (interval_.count() > 0) { - delayWorker(); + if (config_["exec"].isString()) { + if (interval_.count() > 0) { + delayWorker(); + } else { + continuousWorker(); + } } else { - continuousWorker(); + update(); } } @@ -66,7 +67,7 @@ void waybar::modules::Custom::continuousWorker() auto waybar::modules::Custom::update() -> void { // Hide label if output is empty - if (output_.out.empty() || output_.exit_code != 0) { + if (config_["exec"].isString() && (output_.out.empty() || output_.exit_code != 0)) { label_.hide(); label_.set_name(""); } else { @@ -132,4 +133,4 @@ void waybar::modules::Custom::parseOutputJson() class_ = parsed["class"].asString(); break; } -} \ No newline at end of file +}