#include #include "drawtypes/iconset.hpp" #include "drawtypes/label.hpp" #include "modules/bspwm.hpp" #include "utils/file.hpp" #include "modules/meta/base.inl" #include "modules/meta/event_module.inl" POLYBAR_NS namespace modules { template class module; template class event_module; void bspwm_module::setup() { auto socket_path = bspwm_util::get_socket_path(); if (!file_util::exists(socket_path)) { throw module_error("Could not find socket: " + (socket_path.empty() ? "" : socket_path)); } // Create ipc subscriber m_subscriber = bspwm_util::make_subscriber(); // Load configuration values GET_CONFIG_VALUE(name(), m_pinworkspaces, "pin-workspaces"); GET_CONFIG_VALUE(name(), m_click, "enable-click"); GET_CONFIG_VALUE(name(), m_scroll, "enable-scroll"); // Add formats and create components m_formatter->add(DEFAULT_FORMAT, TAG_LABEL_STATE, {TAG_LABEL_STATE}, {TAG_LABEL_MONITOR, TAG_LABEL_MODE}); if (m_formatter->has(TAG_LABEL_MONITOR)) { m_monitorlabel = load_optional_label(m_conf, name(), "label-monitor", DEFAULT_MONITOR_LABEL); } if (m_formatter->has(TAG_LABEL_STATE)) { m_statelabels.insert( make_pair(state_ws::WORKSPACE_ACTIVE, load_optional_label(m_conf, name(), "label-active", DEFAULT_WS_LABEL))); m_statelabels.insert(make_pair( state_ws::WORKSPACE_OCCUPIED, load_optional_label(m_conf, name(), "label-occupied", DEFAULT_WS_LABEL))); m_statelabels.insert( make_pair(state_ws::WORKSPACE_URGENT, load_optional_label(m_conf, name(), "label-urgent", DEFAULT_WS_LABEL))); m_statelabels.insert( make_pair(state_ws::WORKSPACE_EMPTY, load_optional_label(m_conf, name(), "label-empty", DEFAULT_WS_LABEL))); m_statelabels.insert(make_pair(state_ws::WORKSPACE_DIMMED, load_optional_label(m_conf, name(), "label-dimmed"))); m_statelabels.insert( make_pair(state_ws::WORKSPACE_DIMMED_ACTIVE, load_optional_label(m_conf, name(), "label-dimmed-active"))); m_statelabels.insert( make_pair(state_ws::WORKSPACE_DIMMED_URGENT, load_optional_label(m_conf, name(), "label-dimmed-urgent"))); m_statelabels.insert( make_pair(state_ws::WORKSPACE_DIMMED_EMPTY, load_optional_label(m_conf, name(), "label-dimmed-empty"))); m_statelabels.insert( make_pair(state_ws::WORKSPACE_DIMMED_OCCUPIED, load_optional_label(m_conf, name(), "label-dimmed-occupied"))); } if (m_formatter->has(TAG_LABEL_MODE)) { m_modelabels.insert( make_pair(state_mode::MODE_LAYOUT_MONOCLE, load_optional_label(m_conf, name(), "label-monocle"))); m_modelabels.insert(make_pair(state_mode::MODE_LAYOUT_TILED, load_optional_label(m_conf, name(), "label-tiled"))); m_modelabels.insert( make_pair(state_mode::MODE_STATE_FULLSCREEN, load_optional_label(m_conf, name(), "label-fullscreen"))); m_modelabels.insert( make_pair(state_mode::MODE_STATE_FLOATING, load_optional_label(m_conf, name(), "label-floating"))); m_modelabels.insert(make_pair(state_mode::MODE_NODE_LOCKED, load_optional_label(m_conf, name(), "label-locked"))); m_modelabels.insert(make_pair(state_mode::MODE_NODE_STICKY, load_optional_label(m_conf, name(), "label-sticky"))); m_modelabels.insert( make_pair(state_mode::MODE_NODE_PRIVATE, load_optional_label(m_conf, name(), "label-private"))); } m_icons = make_shared(); m_icons->add(DEFAULT_WS_ICON, make_shared