2016-05-30 23:58:58 -04:00
|
|
|
#pragma once
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-10-11 21:57:22 -04:00
|
|
|
#include <i3ipc++/ipc.hpp>
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-10-11 21:57:22 -04:00
|
|
|
#include "components/config.hpp"
|
2016-10-18 05:49:13 -04:00
|
|
|
#include "config.hpp"
|
2016-11-20 17:04:31 -05:00
|
|
|
#include "modules/meta/event_module.hpp"
|
2016-10-11 21:57:22 -04:00
|
|
|
#include "utils/i3.hpp"
|
|
|
|
#include "utils/io.hpp"
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
namespace modules {
|
2016-10-11 21:57:22 -04:00
|
|
|
// meta types {{{
|
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
enum class i3_flag {
|
|
|
|
WORKSPACE_NONE,
|
|
|
|
WORKSPACE_FOCUSED,
|
|
|
|
WORKSPACE_UNFOCUSED,
|
|
|
|
WORKSPACE_VISIBLE,
|
|
|
|
WORKSPACE_URGENT,
|
|
|
|
};
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
struct i3_workspace {
|
2016-10-11 21:57:22 -04:00
|
|
|
int index;
|
|
|
|
i3_flag flag;
|
|
|
|
label_t label;
|
|
|
|
|
|
|
|
i3_workspace(int index_, i3_flag flag_, label_t&& label_)
|
|
|
|
: index(index_), flag(flag_), label(forward<decltype(label_)>(label_)) {}
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-11-19 09:49:03 -05:00
|
|
|
operator bool();
|
2016-06-14 23:32:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
using i3_workspace_t = unique_ptr<i3_workspace>;
|
|
|
|
|
2016-10-11 21:57:22 -04:00
|
|
|
// }}}
|
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
class i3_module : public event_module<i3_module> {
|
|
|
|
public:
|
|
|
|
using event_module::event_module;
|
|
|
|
|
2016-11-02 15:22:45 -04:00
|
|
|
void setup();
|
|
|
|
void stop();
|
|
|
|
bool has_event();
|
|
|
|
bool update();
|
2016-11-25 07:55:15 -05:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-11-02 15:22:45 -04:00
|
|
|
bool handle_event(string cmd);
|
2016-11-11 17:57:12 -05:00
|
|
|
bool receive_events() const {
|
|
|
|
return true;
|
|
|
|
}
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
private:
|
2016-10-11 23:19:29 -04:00
|
|
|
static constexpr auto DEFAULT_WS_ICON = "ws-icon-default";
|
2016-06-14 23:32:35 -04:00
|
|
|
static constexpr auto DEFAULT_WS_LABEL = "%icon% %name%";
|
|
|
|
static constexpr auto TAG_LABEL_STATE = "<label-state>";
|
2016-10-14 14:41:36 -04:00
|
|
|
|
|
|
|
static constexpr auto EVENT_PREFIX = "i3";
|
2016-10-11 22:14:28 -04:00
|
|
|
static constexpr auto EVENT_CLICK = "i3-wsfocus-";
|
2016-10-14 14:41:36 -04:00
|
|
|
static constexpr auto EVENT_SCROLL_UP = "i3-wsnext";
|
|
|
|
static constexpr auto EVENT_SCROLL_DOWN = "i3-wsprev";
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
map<i3_flag, label_t> m_statelabels;
|
|
|
|
vector<i3_workspace_t> m_workspaces;
|
|
|
|
iconset_t m_icons;
|
|
|
|
|
2016-11-11 17:57:12 -05:00
|
|
|
bool m_click = true;
|
|
|
|
bool m_scroll = true;
|
2016-10-11 22:14:06 -04:00
|
|
|
bool m_indexsort = false;
|
2016-10-11 21:57:22 -04:00
|
|
|
bool m_pinworkspaces = false;
|
2016-10-14 14:41:36 -04:00
|
|
|
bool m_strip_wsnumbers = false;
|
2016-10-11 21:57:22 -04:00
|
|
|
size_t m_wsname_maxlen = 0;
|
|
|
|
|
|
|
|
i3_util::connection_t m_ipc;
|
2016-05-19 10:41:06 -04:00
|
|
|
};
|
|
|
|
}
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|