#include "modules/xkeyboard.hpp" #include "drawtypes/iconset.hpp" #include "drawtypes/label.hpp" #include "modules/meta/base.inl" #include "utils/factory.hpp" #include "x11/atoms.hpp" #include "x11/connection.hpp" POLYBAR_NS namespace modules { template class module; // clang-format off static const keyboard::indicator::type INDICATOR_TYPES[] { keyboard::indicator::type::CAPS_LOCK, keyboard::indicator::type::NUM_LOCK, keyboard::indicator::type::SCROLL_LOCK }; // clang-format on /** * Construct module */ xkeyboard_module::xkeyboard_module(const bar_settings& bar, string name_) : static_module(bar, move(name_)), m_connection(connection::make()) { m_router->register_action(EVENT_SWITCH, &xkeyboard_module::action_switch); // Setup extension // clang-format off m_connection.xkb().select_events_checked(XCB_XKB_ID_USE_CORE_KBD, XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY | XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_INDICATOR_STATE_NOTIFY, 0, XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY | XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_INDICATOR_STATE_NOTIFY, 0, 0, nullptr); // clang-format on // Create keyboard object query_keyboard(); // Load config values m_blacklist = m_conf.get_list(name(), "blacklist", {}); // load layout icons m_layout_icons = factory_util::shared(); m_layout_icons->add(DEFAULT_LAYOUT_ICON, load_optional_label(m_conf, name(), DEFAULT_LAYOUT_ICON, ""s)); for (const auto& it : m_conf.get_list(name(), "layout-icon", {})) { auto vec = string_util::tokenize(it, ';'); if (vec.size() == 2) { m_layout_icons->add(vec[0], factory_util::shared