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-11-20 17:04:31 -05:00
|
|
|
#include "modules/meta/event_module.hpp"
|
2023-05-08 13:36:12 -04:00
|
|
|
#include "modules/meta/types.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 {
|
2019-12-02 13:14:26 -05:00
|
|
|
class i3_module : public event_module<i3_module> {
|
2016-11-30 12:23:11 -05:00
|
|
|
public:
|
|
|
|
enum class state {
|
|
|
|
NONE,
|
2017-01-26 21:23:42 -05:00
|
|
|
/**
|
2022-02-20 15:40:48 -05:00
|
|
|
* @brief Active workspace on focused monitor
|
2017-01-26 21:23:42 -05:00
|
|
|
*/
|
2016-11-30 12:23:11 -05:00
|
|
|
FOCUSED,
|
2017-01-26 21:23:42 -05:00
|
|
|
/**
|
2022-02-20 15:40:48 -05:00
|
|
|
* @brief Inactive workspace on any monitor
|
2017-01-26 21:23:42 -05:00
|
|
|
*/
|
2016-11-30 12:23:11 -05:00
|
|
|
UNFOCUSED,
|
2017-01-26 21:23:42 -05:00
|
|
|
/**
|
2022-02-20 15:40:48 -05:00
|
|
|
* @brief Active workspace on unfocused monitor
|
2017-01-26 21:23:42 -05:00
|
|
|
*/
|
2016-11-30 12:23:11 -05:00
|
|
|
VISIBLE,
|
2017-01-26 21:23:42 -05:00
|
|
|
/**
|
2022-02-20 15:40:48 -05:00
|
|
|
* @brief Workspace with urgency hint set
|
2017-01-26 21:23:42 -05:00
|
|
|
*/
|
2016-11-30 12:23:11 -05:00
|
|
|
URGENT,
|
|
|
|
};
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-11-30 12:23:11 -05:00
|
|
|
struct workspace {
|
2017-04-05 23:22:11 -04:00
|
|
|
explicit workspace(string name, enum state state_, label_t&& label)
|
|
|
|
: name(name), state(state_), label(forward<label_t>(label)) {}
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-30 12:23:11 -05:00
|
|
|
operator bool();
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2017-04-05 23:22:11 -04:00
|
|
|
string name;
|
2016-11-30 15:17:30 -05:00
|
|
|
enum state state;
|
2016-11-30 12:23:11 -05:00
|
|
|
label_t label;
|
|
|
|
};
|
2016-10-11 21:57:22 -04:00
|
|
|
|
2016-12-21 02:00:09 -05:00
|
|
|
public:
|
2023-05-01 08:58:52 -04:00
|
|
|
explicit i3_module(const bar_settings&, string, const config&);
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2021-01-04 04:38:43 -05:00
|
|
|
void stop() override;
|
2016-11-02 15:22:45 -04:00
|
|
|
bool has_event();
|
|
|
|
bool update();
|
2016-11-25 07:55:15 -05:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-12-21 02:38:44 -05:00
|
|
|
|
2023-05-08 13:36:12 -04:00
|
|
|
static constexpr auto TYPE = I3_TYPE;
|
2020-05-15 13:59:08 -04:00
|
|
|
|
2020-05-24 12:35:12 -04:00
|
|
|
static constexpr auto EVENT_FOCUS = "focus";
|
|
|
|
static constexpr auto EVENT_NEXT = "next";
|
|
|
|
static constexpr auto EVENT_PREV = "prev";
|
|
|
|
|
2016-12-21 02:38:44 -05:00
|
|
|
protected:
|
2021-01-04 04:25:52 -05:00
|
|
|
void action_focus(const string& ws);
|
|
|
|
void action_next();
|
|
|
|
void action_prev();
|
|
|
|
|
|
|
|
void focus_direction(bool next);
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
private:
|
2019-06-04 17:34:16 -04:00
|
|
|
static string make_workspace_command(const string& workspace);
|
|
|
|
|
2016-11-30 12:23:11 -05: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 14:41:36 -04:00
|
|
|
|
2016-11-30 12:23:11 -05:00
|
|
|
static constexpr const char* TAG_LABEL_STATE{"<label-state>"};
|
|
|
|
static constexpr const char* TAG_LABEL_MODE{"<label-mode>"};
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-30 12:23:11 -05:00
|
|
|
map<state, label_t> m_statelabels;
|
|
|
|
vector<unique_ptr<workspace>> m_workspaces;
|
2016-06-14 23:32:35 -04:00
|
|
|
iconset_t m_icons;
|
|
|
|
|
2016-11-30 12:23:11 -05:00
|
|
|
label_t m_modelabel;
|
|
|
|
bool m_modeactive{false};
|
|
|
|
|
2018-01-06 19:19:02 -05:00
|
|
|
/**
|
|
|
|
* Separator that is inserted in between workspaces
|
|
|
|
*/
|
|
|
|
label_t m_labelseparator;
|
|
|
|
|
2016-12-13 18:46:33 -05:00
|
|
|
bool m_click{true};
|
|
|
|
bool m_scroll{true};
|
2016-12-14 11:18:20 -05:00
|
|
|
bool m_revscroll{true};
|
2016-12-13 18:46:33 -05:00
|
|
|
bool m_wrap{true};
|
|
|
|
bool m_indexsort{false};
|
|
|
|
bool m_pinworkspaces{false};
|
2021-02-15 15:31:34 -05:00
|
|
|
bool m_show_urgent{false};
|
2016-12-13 18:46:33 -05:00
|
|
|
bool m_strip_wsnumbers{false};
|
2017-01-19 23:35:52 -05:00
|
|
|
bool m_fuzzy_match{false};
|
2016-10-11 21:57:22 -04:00
|
|
|
|
2016-11-30 12:23:11 -05:00
|
|
|
unique_ptr<i3_util::connection_t> m_ipc;
|
2016-05-19 10:41:06 -04:00
|
|
|
};
|
2019-06-04 17:34:16 -04:00
|
|
|
} // namespace modules
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|