polybar/include/modules/i3.hpp

105 lines
2.5 KiB
C++
Raw Normal View History

#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-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 {
class i3_module : public event_module<i3_module> {
2016-11-30 17:23:11 +00:00
public:
enum class state {
NONE,
2017-01-27 02:23:42 +00:00
/**
* \brief Active workspace on focused monitor
2017-01-27 02:23:42 +00:00
*/
2016-11-30 17:23:11 +00:00
FOCUSED,
2017-01-27 02:23:42 +00:00
/**
* \brief Inactive workspace on any monitor
2017-01-27 02:23:42 +00:00
*/
2016-11-30 17:23:11 +00:00
UNFOCUSED,
2017-01-27 02:23:42 +00:00
/**
* \brief Active workspace on unfocused monitor
2017-01-27 02:23:42 +00:00
*/
2016-11-30 17:23:11 +00:00
VISIBLE,
2017-01-27 02:23:42 +00:00
/**
* \brief Workspace with urgency hint set
2017-01-27 02:23:42 +00:00
*/
2016-11-30 17:23:11 +00:00
URGENT,
};
2016-05-19 14:41:06 +00:00
2016-11-30 17:23:11 +00:00
struct workspace {
explicit workspace(string name, enum state state_, label_t&& label)
: name(name), 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
string name;
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
public:
explicit i3_module(const bar_settings&, string);
2016-06-15 03:32:35 +00:00
void stop() override;
2016-11-02 19:22:45 +00:00
bool has_event();
bool update();
2016-11-25 12:55:15 +00:00
bool build(builder* builder, const string& tag) const;
static constexpr auto TYPE = "internal/i3";
static constexpr auto EVENT_FOCUS = "focus";
static constexpr auto EVENT_NEXT = "next";
static constexpr auto EVENT_PREV = "prev";
protected:
void action_focus(const string& ws);
void action_next();
void action_prev();
void focus_direction(bool next);
2016-06-15 03:32:35 +00:00
private:
static string make_workspace_command(const string& workspace);
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-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-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};
/**
* Separator that is inserted in between workspaces
*/
label_t m_labelseparator;
bool m_click{true};
bool m_scroll{true};
bool m_revscroll{true};
bool m_wrap{true};
bool m_indexsort{false};
bool m_pinworkspaces{false};
bool m_show_urgent{false};
bool m_strip_wsnumbers{false};
bool m_fuzzy_match{false};
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
};
} // namespace modules
2016-06-15 03:32:35 +00:00
2016-11-19 05:22:44 +00:00
POLYBAR_NS_END