diff --git a/include/modules/bspwm.hpp b/include/modules/bspwm.hpp index 5e9a07be..b1b02a7a 100644 --- a/include/modules/bspwm.hpp +++ b/include/modules/bspwm.hpp @@ -51,6 +51,8 @@ namespace modules { bool input(string&& cmd); private: + bool handle_status(string& data); + static constexpr auto DEFAULT_ICON = "ws-icon-default"; static constexpr auto DEFAULT_LABEL = "%icon% %name%"; static constexpr auto DEFAULT_MONITOR_LABEL = "%name%"; diff --git a/src/modules/bspwm.cpp b/src/modules/bspwm.cpp index cd036ad9..0ae8e725 100644 --- a/src/modules/bspwm.cpp +++ b/src/modules/bspwm.cpp @@ -157,12 +157,18 @@ namespace modules { } string data{m_subscriber->receive(BUFSIZ)}; + bool result = false; - size_t pos; - if ((pos = data.find('\n')) != string::npos) { - data.erase(pos); + for (auto&& status_line : string_util::split(data, '\n')) { + // Need to return true if ANY of the handle_status calls + // return true + result = this->handle_status(status_line) || result; } + return result; + } + + bool bspwm_module::handle_status(string& data) { if (data.empty()) { return false; } @@ -180,6 +186,8 @@ namespace modules { m_hash = hash; + size_t pos; + // Extract the string for the defined monitor if (m_pinworkspaces) { const auto needle_active = ":M" + m_bar.monitor->name + ":";