From 1fe679d6b3ec5203b08887b616738e9d50a669e5 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Wed, 11 Dec 2019 21:32:43 +0100 Subject: [PATCH] fix(ipc): Clear content if no output is produced Before, if the command produced no output, the `m_output` field would not have been overwritten and the old output was displayed. But since this is an explicit trigger of the hook, the user would expect the output to be updated to whatever the script produces (even if that is nothing). Ref: https://www.reddit.com/r/Polybar/comments/e9a8ww --- src/modules/ipc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/ipc.cpp b/src/modules/ipc.cpp index df72beed..18a6c3e1 100644 --- a/src/modules/ipc.cpp +++ b/src/modules/ipc.cpp @@ -1,6 +1,6 @@ #include "modules/ipc.hpp" -#include "components/ipc.hpp" +#include "components/ipc.hpp" #include "modules/meta/base.inl" POLYBAR_NS @@ -112,6 +112,8 @@ namespace modules { m_log.info("%s: Found matching hook (%s)", name(), hook->payload); try { + // Clear the output in case the command produces no output + m_output.clear(); auto command = command_util::make_command(hook->command); command->exec(false); command->tail([this](string line) { m_output = line; }); @@ -123,6 +125,6 @@ namespace modules { broadcast(); } } -} +} // namespace modules POLYBAR_NS_END