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-12-21 07:38:44 +00:00
|
|
|
#include "modules/meta/input_handler.hpp"
|
2016-11-30 09:06:16 +00:00
|
|
|
#include "modules/meta/static_module.hpp"
|
|
|
|
#include "x11/events.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>,
|
2016-12-23 04:08:19 +00:00
|
|
|
public event_handler<evt::xkb_new_keyboard_notify, evt::xkb_state_notify, evt::xkb_indicator_state_notify>,
|
2016-12-21 07:38:44 +00:00
|
|
|
public input_handler {
|
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;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool query_keyboard();
|
|
|
|
bool blacklisted(const string& indicator_name);
|
|
|
|
|
|
|
|
void handle(const evt::xkb_new_keyboard_notify& evt);
|
2016-12-08 17:35:06 +00:00
|
|
|
void handle(const evt::xkb_state_notify& evt);
|
2016-11-30 09:06:16 +00:00
|
|
|
void handle(const evt::xkb_indicator_state_notify& evt);
|
|
|
|
|
2016-12-23 19:43:52 +00:00
|
|
|
bool input(string&& cmd);
|
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>"};
|
|
|
|
|
2016-12-16 10:26:28 +00:00
|
|
|
static constexpr const char* EVENT_SWITCH{"xkeyboard/switch"};
|
|
|
|
|
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;
|
|
|
|
label_t m_indicator;
|
|
|
|
map<keyboard::indicator::type, label_t> m_indicators;
|
|
|
|
|
|
|
|
vector<string> m_blacklist;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
POLYBAR_NS_END
|