#include #include "drawtypes/iconset.hpp" #include "drawtypes/label.hpp" #include "modules/i3.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; i3_module::workspace::operator bool() { return label && *label; } void i3_module::setup() { auto socket_path = i3ipc::get_socketpath(); if (!file_util::exists(socket_path)) { throw module_error("Could not find socket: " + (socket_path.empty() ? "" : socket_path)); } m_ipc = make_unique(); // Load configuration values GET_CONFIG_VALUE(name(), m_click, "enable-click"); GET_CONFIG_VALUE(name(), m_scroll, "enable-scroll"); GET_CONFIG_VALUE(name(), m_indexsort, "index-sort"); GET_CONFIG_VALUE(name(), m_pinworkspaces, "pin-workspaces"); GET_CONFIG_VALUE(name(), m_strip_wsnumbers, "strip-wsnumbers"); GET_CONFIG_VALUE(name(), m_wsname_maxlen, "wsname-maxlen"); // Add formats and create components m_formatter->add(DEFAULT_FORMAT, DEFAULT_TAGS, {TAG_LABEL_STATE, TAG_LABEL_MODE}); if (m_formatter->has(TAG_LABEL_STATE)) { m_statelabels.insert( make_pair(state::FOCUSED, load_optional_label(m_conf, name(), "label-focused", DEFAULT_WS_LABEL))); m_statelabels.insert( make_pair(state::UNFOCUSED, load_optional_label(m_conf, name(), "label-unfocused", DEFAULT_WS_LABEL))); m_statelabels.insert( make_pair(state::VISIBLE, load_optional_label(m_conf, name(), "label-visible", DEFAULT_WS_LABEL))); m_statelabels.insert( make_pair(state::URGENT, load_optional_label(m_conf, name(), "label-urgent", DEFAULT_WS_LABEL))); } if (m_formatter->has(TAG_LABEL_MODE)) { m_modelabel = load_optional_label(m_conf, name(), "label-mode", "%mode%"); } m_icons = make_shared(); m_icons->add(DEFAULT_WS_ICON, make_shared