diff --git a/include/modules/bspwm.hpp b/include/modules/bspwm.hpp index 17ce8c9f..1b57bac3 100644 --- a/include/modules/bspwm.hpp +++ b/include/modules/bspwm.hpp @@ -43,9 +43,19 @@ namespace modules { public: using event_module::event_module; + ~bspwm_module() { + if (m_subscriber) + m_subscriber->disconnect(); + } + void setup() { + m_monitor = m_bar.monitor->name; + m_log.trace("%s: Primary monitor '%s'", name(), m_monitor); + m_subscriber = bspwm_util::make_subscriber(); + // Add formats and create components {{{ + m_formatter->add(DEFAULT_FORMAT, TAG_LABEL_STATE, {TAG_LABEL_STATE}, {TAG_LABEL_MODE}); if (m_formatter->has(TAG_LABEL_STATE)) { @@ -78,8 +88,7 @@ namespace modules { get_optional_config_label(m_conf, name(), "label-private"))); } - m_monitor = m_bar.monitor->name; - m_log.trace("%s: Primary monitor '%s'", name(), m_monitor); + // }}} m_icons = iconset_t{new iconset()}; m_icons->add( @@ -93,15 +102,6 @@ namespace modules { } } - void start() { - event_module::start(); - } - - void stop() { - event_module::stop(); - m_subscriber && m_subscriber->disconnect(); - } - bool has_event() { if (m_subscriber->poll(POLLHUP, 0)) { m_log.warn("%s: Reconnecting to socket...", name());