polybar/include/modules/bspwm.hpp

98 lines
2.3 KiB
C++
Raw Normal View History

#pragma once
2016-05-19 14:41:06 +00:00
2016-11-20 22:04:31 +00:00
#include "modules/meta/event_module.hpp"
#include "modules/meta/input_handler.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 {
class bspwm_module : public event_module<bspwm_module>, public input_handler {
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,
STATE_PSEUDOTILED,
2016-11-30 20:03:28 +00:00
NODE_LOCKED,
NODE_STICKY,
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
};
public:
explicit bspwm_module(const bar_settings&, string);
2016-06-15 03:32:35 +00:00
2016-11-02 19:22:45 +00:00
void stop();
bool has_event();
bool update();
string get_output();
2016-11-25 12:55:15 +00:00
bool build(builder* builder, const string& tag) const;
protected:
2016-12-23 19:43:52 +00:00
bool input(string&& cmd);
2016-06-15 03:32:35 +00:00
private:
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%";
static constexpr auto DEFAULT_MONITOR_LABEL = "%name%";
2016-11-30 20:03:28 +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-12-05 13:02:16 +00:00
static constexpr const char* EVENT_PREFIX{"bspwm-desk"};
static constexpr const char* EVENT_CLICK{"bspwm-deskfocus"};
static constexpr const char* EVENT_SCROLL_UP{"bspwm-desknext"};
static constexpr const char* EVENT_SCROLL_DOWN{"bspwm-deskprev"};
2016-06-15 03:32:35 +00:00
bspwm_util::connection_t m_subscriber;
2016-06-15 03:32:35 +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;
label_t m_monitorlabel;
2016-06-15 03:32:35 +00:00
iconset_t m_icons;
/**
* 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};
bool m_revscroll{true};
2016-12-14 06:45:29 +00:00
bool m_pinworkspaces{true};
bool m_inlinemode{false};
2016-12-14 06:45:29 +00:00
string_util::hash_type m_hash{0U};
bool m_fuzzy_match{false};
// 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
};
}
2016-06-15 03:32:35 +00:00
2016-11-19 05:22:44 +00:00
POLYBAR_NS_END