2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/event_module.hpp"
|
2016-06-15 03:32:35 +00:00
|
|
|
#include "utils/bspwm.hpp"
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
namespace modules {
|
2019-12-02 18:14:26 +00:00
|
|
|
class bspwm_module : public event_module<bspwm_module> {
|
2016-06-15 03:32:35 +00:00
|
|
|
public:
|
2016-11-30 20:03:28 +00:00
|
|
|
enum class state {
|
|
|
|
NONE = 0U,
|
|
|
|
EMPTY,
|
|
|
|
OCCUPIED,
|
|
|
|
FOCUSED,
|
|
|
|
URGENT,
|
|
|
|
DIMMED, // used when the monitor is out of focus
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class mode {
|
|
|
|
NONE = 0U,
|
|
|
|
LAYOUT_MONOCLE,
|
|
|
|
LAYOUT_TILED,
|
|
|
|
STATE_FULLSCREEN,
|
|
|
|
STATE_FLOATING,
|
2016-12-30 02:51:39 +00:00
|
|
|
STATE_PSEUDOTILED,
|
2016-11-30 20:03:28 +00:00
|
|
|
NODE_LOCKED,
|
|
|
|
NODE_STICKY,
|
2018-12-26 09:52:16 +00:00
|
|
|
NODE_PRIVATE,
|
|
|
|
NODE_MARKED
|
2016-11-30 20:03:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bspwm_monitor {
|
2017-01-19 10:11:28 +00:00
|
|
|
vector<pair<unsigned int, label_t>> workspaces;
|
2016-11-30 20:03:28 +00:00
|
|
|
vector<label_t> modes;
|
|
|
|
label_t label;
|
|
|
|
string name;
|
2016-12-14 06:45:29 +00:00
|
|
|
bool focused{false};
|
2016-11-30 20:03:28 +00:00
|
|
|
};
|
|
|
|
|
2016-12-21 07:00:09 +00:00
|
|
|
public:
|
2023-05-01 12:58:52 +00:00
|
|
|
explicit bspwm_module(const bar_settings&, string, const config&);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2021-01-04 09:38:43 +00:00
|
|
|
void stop() override;
|
2016-11-02 19:22:45 +00:00
|
|
|
bool has_event();
|
|
|
|
bool update();
|
2016-11-03 16:54:26 +00:00
|
|
|
string get_output();
|
2016-11-25 12:55:15 +00:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-12-21 07:38:44 +00:00
|
|
|
|
2020-05-15 17:59:08 +00:00
|
|
|
static constexpr auto TYPE = "internal/bspwm";
|
|
|
|
|
2020-05-24 16:35:12 +00:00
|
|
|
static constexpr auto EVENT_FOCUS = "focus";
|
|
|
|
static constexpr auto EVENT_NEXT = "next";
|
|
|
|
static constexpr auto EVENT_PREV = "prev";
|
|
|
|
|
2016-12-21 07:38:44 +00:00
|
|
|
protected:
|
2021-01-04 09:25:52 +00:00
|
|
|
void action_focus(const string& data);
|
|
|
|
void action_next();
|
|
|
|
void action_prev();
|
|
|
|
|
|
|
|
void focus_direction(bool next);
|
|
|
|
void send_command(const string& payload_cmd, const string& log_info);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
private:
|
2017-02-21 13:23:16 +00:00
|
|
|
bool handle_status(string& data);
|
|
|
|
|
2016-11-30 20:03:28 +00:00
|
|
|
static constexpr auto DEFAULT_ICON = "ws-icon-default";
|
|
|
|
static constexpr auto DEFAULT_LABEL = "%icon% %name%";
|
2016-11-03 16:54:26 +00:00
|
|
|
static constexpr auto DEFAULT_MONITOR_LABEL = "%name%";
|
2016-11-30 20:03:28 +00:00
|
|
|
|
2016-11-03 16:54:26 +00:00
|
|
|
static constexpr auto TAG_LABEL_MONITOR = "<label-monitor>";
|
2016-06-15 03:32:35 +00:00
|
|
|
static constexpr auto TAG_LABEL_STATE = "<label-state>";
|
|
|
|
static constexpr auto TAG_LABEL_MODE = "<label-mode>";
|
2016-11-30 20:03:28 +00:00
|
|
|
|
2016-10-11 07:25:32 +00:00
|
|
|
bspwm_util::connection_t m_subscriber;
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-03 16:54:26 +00:00
|
|
|
vector<unique_ptr<bspwm_monitor>> m_monitors;
|
|
|
|
|
2016-11-30 20:03:28 +00:00
|
|
|
map<mode, label_t> m_modelabels;
|
2017-01-19 10:11:28 +00:00
|
|
|
map<unsigned int, label_t> m_statelabels;
|
2016-11-03 16:54:26 +00:00
|
|
|
label_t m_monitorlabel;
|
2016-06-15 03:32:35 +00:00
|
|
|
iconset_t m_icons;
|
2016-11-12 12:37:07 +00:00
|
|
|
|
2018-01-07 00:18:09 +00:00
|
|
|
/**
|
|
|
|
* Separator that is inserted in between workspaces
|
|
|
|
*/
|
|
|
|
label_t m_labelseparator;
|
|
|
|
|
2016-12-14 06:45:29 +00:00
|
|
|
bool m_click{true};
|
|
|
|
bool m_scroll{true};
|
2021-05-13 10:59:13 +00:00
|
|
|
bool m_occscroll{false};
|
2016-12-14 16:18:20 +00:00
|
|
|
bool m_revscroll{true};
|
2016-12-14 06:45:29 +00:00
|
|
|
bool m_pinworkspaces{true};
|
2017-01-01 15:39:25 +00:00
|
|
|
bool m_inlinemode{false};
|
2016-12-14 06:45:29 +00:00
|
|
|
string_util::hash_type m_hash{0U};
|
2017-01-20 04:35:52 +00:00
|
|
|
bool m_fuzzy_match{false};
|
2016-11-03 16:54:26 +00:00
|
|
|
|
|
|
|
// used while formatting output
|
2016-12-14 06:45:29 +00:00
|
|
|
size_t m_index{0U};
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
2020-05-15 17:59:08 +00:00
|
|
|
} // namespace modules
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|