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