From 9238f56b7272e12d31a55e21fde9bf77ef2e35a0 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 14 Oct 2016 17:18:29 +0200 Subject: [PATCH] fix(script): Broadcast empty content once --- include/modules/script.hpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/modules/script.hpp b/include/modules/script.hpp index 478e9cb5..9bf7cc3f 100644 --- a/include/modules/script.hpp +++ b/include/modules/script.hpp @@ -44,6 +44,8 @@ namespace modules { } bool update() { + auto previous_output = m_output; + m_output.clear(); if (m_tail) { @@ -52,13 +54,23 @@ namespace modules { m_output = read_output(); } + if (m_output != previous_output) + m_broadcasted = false; + if (m_maxlen > 0 && m_output.length() > m_maxlen) { m_output.erase(m_maxlen); if (m_ellipsis) m_output += "..."; } - return enabled() && !m_output.empty(); + if (!enabled()) + return false; + else if (m_output.empty() && !m_broadcasted) + return true; + else if (m_output.empty()) + return false; + else + return true; } string get_output() { @@ -175,6 +187,8 @@ namespace modules { size_t m_maxlen = 0; bool m_ellipsis = true; + + stateflag m_broadcasted{false}; }; }