2016-11-30 04:06:16 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
|
|
|
#include "components/config.hpp"
|
|
|
|
#include "components/types.hpp"
|
2016-12-22 23:08:19 -05:00
|
|
|
#include "modules/meta/event_handler.hpp"
|
2016-11-30 04:06:16 -05:00
|
|
|
#include "modules/meta/static_module.hpp"
|
2016-12-21 08:55:19 -05:00
|
|
|
#include "x11/extensions/xkb.hpp"
|
2016-12-22 23:08:19 -05:00
|
|
|
#include "x11/window.hpp"
|
2016-11-30 04:06:16 -05:00
|
|
|
|
|
|
|
POLYBAR_NS
|
|
|
|
|
|
|
|
class connection;
|
|
|
|
|
|
|
|
namespace modules {
|
|
|
|
/**
|
|
|
|
* Keyboard module using the X keyboard extension
|
|
|
|
*/
|
2016-12-21 02:38:44 -05:00
|
|
|
class xkeyboard_module
|
|
|
|
: public static_module<xkeyboard_module>,
|
2019-12-02 13:14:26 -05:00
|
|
|
public event_handler<evt::xkb_new_keyboard_notify, evt::xkb_state_notify, evt::xkb_indicator_state_notify> {
|
2016-11-30 04:06:16 -05:00
|
|
|
public:
|
2016-12-21 02:00:09 -05:00
|
|
|
explicit xkeyboard_module(const bar_settings& bar, string name_);
|
2016-11-30 04:06:16 -05:00
|
|
|
|
2016-12-23 16:39:59 -05:00
|
|
|
string get_output();
|
2016-11-30 04:06:16 -05:00
|
|
|
void update();
|
|
|
|
bool build(builder* builder, const string& tag) const;
|
|
|
|
|
2020-05-15 13:59:08 -04:00
|
|
|
static constexpr auto TYPE = "internal/xkeyboard";
|
|
|
|
|
2020-05-24 12:35:12 -04:00
|
|
|
static constexpr const char* EVENT_SWITCH = "switch";
|
|
|
|
|
2016-11-30 04:06:16 -05:00
|
|
|
protected:
|
|
|
|
bool query_keyboard();
|
|
|
|
bool blacklisted(const string& indicator_name);
|
|
|
|
|
2021-01-04 04:38:43 -05:00
|
|
|
void handle(const evt::xkb_new_keyboard_notify& evt) override;
|
|
|
|
void handle(const evt::xkb_state_notify& evt) override;
|
|
|
|
void handle(const evt::xkb_indicator_state_notify& evt) override;
|
2016-11-30 04:06:16 -05:00
|
|
|
|
2021-01-04 04:25:52 -05:00
|
|
|
void action_switch();
|
2016-12-21 02:38:44 -05:00
|
|
|
|
2016-11-30 04:06:16 -05:00
|
|
|
private:
|
|
|
|
static constexpr const char* TAG_LABEL_LAYOUT{"<label-layout>"};
|
|
|
|
static constexpr const char* TAG_LABEL_INDICATOR{"<label-indicator>"};
|
|
|
|
static constexpr const char* FORMAT_DEFAULT{"<label-layout> <label-indicator>"};
|
2019-02-24 16:35:39 -05:00
|
|
|
static constexpr const char* DEFAULT_LAYOUT_ICON{"layout-icon-default"};
|
|
|
|
static constexpr const char* DEFAULT_INDICATOR_ICON{"indicator-icon-default"};
|
2020-05-15 13:59:08 -04:00
|
|
|
|
2016-11-30 04:06:16 -05:00
|
|
|
connection& m_connection;
|
2017-01-09 10:40:26 -05:00
|
|
|
event_timer m_xkb_newkb_notify{};
|
|
|
|
event_timer m_xkb_state_notify{};
|
|
|
|
event_timer m_xkb_indicator_notify{};
|
2016-11-30 04:06:16 -05:00
|
|
|
unique_ptr<keyboard> m_keyboard;
|
|
|
|
|
|
|
|
label_t m_layout;
|
2019-02-24 16:35:39 -05:00
|
|
|
label_t m_indicator_state_on;
|
|
|
|
label_t m_indicator_state_off;
|
2016-11-30 04:06:16 -05:00
|
|
|
map<keyboard::indicator::type, label_t> m_indicators;
|
2019-02-24 16:35:39 -05:00
|
|
|
map<keyboard::indicator::type, label_t> m_indicator_on_labels;
|
|
|
|
map<keyboard::indicator::type, label_t> m_indicator_off_labels;
|
2016-11-30 04:06:16 -05:00
|
|
|
|
|
|
|
vector<string> m_blacklist;
|
2019-02-24 16:35:39 -05:00
|
|
|
iconset_t m_layout_icons;
|
|
|
|
iconset_t m_indicator_icons_on;
|
|
|
|
iconset_t m_indicator_icons_off;
|
2016-11-30 04:06:16 -05:00
|
|
|
};
|
2020-05-15 13:59:08 -04:00
|
|
|
} // namespace modules
|
2016-11-30 04:06:16 -05:00
|
|
|
|
|
|
|
POLYBAR_NS_END
|