2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-10-12 01:57:22 +00:00
|
|
|
#include <i3ipc++/ipc.hpp>
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-10-12 01:57:22 +00:00
|
|
|
#include "components/config.hpp"
|
2016-10-18 09:49:13 +00:00
|
|
|
#include "config.hpp"
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/event_module.hpp"
|
2016-10-12 01:57:22 +00:00
|
|
|
#include "utils/i3.hpp"
|
|
|
|
#include "utils/io.hpp"
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
namespace modules {
|
2016-11-30 17:23:11 +00:00
|
|
|
class i3_module : public event_module<i3_module> {
|
|
|
|
public:
|
|
|
|
enum class state {
|
|
|
|
NONE,
|
|
|
|
FOCUSED,
|
|
|
|
UNFOCUSED,
|
|
|
|
VISIBLE,
|
|
|
|
URGENT,
|
|
|
|
};
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-11-30 17:23:11 +00:00
|
|
|
struct workspace {
|
2016-11-30 20:17:30 +00:00
|
|
|
explicit workspace(int index, enum state state_, label_t&& label)
|
2016-11-30 17:23:11 +00:00
|
|
|
: index(index), state(state_), label(forward<label_t>(label)) {}
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-30 17:23:11 +00:00
|
|
|
operator bool();
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-30 17:23:11 +00:00
|
|
|
int index;
|
2016-11-30 20:17:30 +00:00
|
|
|
enum state state;
|
2016-11-30 17:23:11 +00:00
|
|
|
label_t label;
|
|
|
|
};
|
2016-10-12 01:57:22 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
using event_module::event_module;
|
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
void setup();
|
|
|
|
void stop();
|
|
|
|
bool has_event();
|
|
|
|
bool update();
|
2016-11-25 12:55:15 +00:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-11-02 19:22:45 +00:00
|
|
|
bool handle_event(string cmd);
|
2016-11-11 22:57:12 +00:00
|
|
|
bool receive_events() const {
|
|
|
|
return true;
|
|
|
|
}
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
private:
|
2016-11-30 17:23:11 +00:00
|
|
|
static constexpr const char* DEFAULT_TAGS{"<label-state> <label-mode>"};
|
|
|
|
static constexpr const char* DEFAULT_MODE{"default"};
|
|
|
|
static constexpr const char* DEFAULT_WS_ICON{"ws-icon-default"};
|
|
|
|
static constexpr const char* DEFAULT_WS_LABEL{"%icon% %name%"};
|
2016-10-14 18:41:36 +00:00
|
|
|
|
2016-11-30 17:23:11 +00:00
|
|
|
static constexpr const char* TAG_LABEL_STATE{"<label-state>"};
|
|
|
|
static constexpr const char* TAG_LABEL_MODE{"<label-mode>"};
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-12-05 12:17:09 +00:00
|
|
|
static constexpr const char* EVENT_PREFIX{"i3wm"};
|
|
|
|
static constexpr const char* EVENT_CLICK{"i3wm-wsfocus-"};
|
|
|
|
static constexpr const char* EVENT_SCROLL_UP{"i3wm-wsnext"};
|
|
|
|
static constexpr const char* EVENT_SCROLL_DOWN{"i3wm-wsprev"};
|
2016-11-30 17:23:11 +00:00
|
|
|
|
|
|
|
map<state, label_t> m_statelabels;
|
|
|
|
vector<unique_ptr<workspace>> m_workspaces;
|
2016-06-15 03:32:35 +00:00
|
|
|
iconset_t m_icons;
|
|
|
|
|
2016-11-30 17:23:11 +00:00
|
|
|
label_t m_modelabel;
|
|
|
|
bool m_modeactive{false};
|
|
|
|
|
2016-12-13 23:46:33 +00:00
|
|
|
bool m_click{true};
|
|
|
|
bool m_scroll{true};
|
|
|
|
bool m_wrap{true};
|
|
|
|
bool m_indexsort{false};
|
|
|
|
bool m_pinworkspaces{false};
|
|
|
|
bool m_strip_wsnumbers{false};
|
|
|
|
size_t m_wsname_maxlen{0};
|
2016-10-12 01:57:22 +00:00
|
|
|
|
2016-11-30 17:23:11 +00:00
|
|
|
unique_ptr<i3_util::connection_t> m_ipc;
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
|
|
|
}
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|