2016-05-30 23:58:58 -04:00
|
|
|
#pragma once
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-11-20 17:04:31 -05:00
|
|
|
#include "modules/meta/event_module.hpp"
|
2016-12-21 02:38:44 -05:00
|
|
|
#include "modules/meta/input_handler.hpp"
|
2016-06-14 23:32:35 -04:00
|
|
|
#include "utils/bspwm.hpp"
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
namespace modules {
|
2016-12-21 02:38:44 -05:00
|
|
|
class bspwm_module : public event_module<bspwm_module>, public input_handler {
|
2016-06-14 23:32:35 -04:00
|
|
|
public:
|
2016-11-30 15:03:28 -05: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,
|
|
|
|
NODE_LOCKED,
|
|
|
|
NODE_STICKY,
|
|
|
|
NODE_PRIVATE
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bspwm_monitor {
|
|
|
|
vector<pair<uint32_t, label_t>> workspaces;
|
|
|
|
vector<label_t> modes;
|
|
|
|
label_t label;
|
|
|
|
string name;
|
2016-12-14 01:45:29 -05:00
|
|
|
bool focused{false};
|
2016-11-30 15:03:28 -05:00
|
|
|
};
|
|
|
|
|
2016-12-21 02:00:09 -05:00
|
|
|
public:
|
|
|
|
explicit bspwm_module(const bar_settings&, string);
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-02 15:22:45 -04:00
|
|
|
void stop();
|
|
|
|
bool has_event();
|
|
|
|
bool update();
|
2016-11-03 12:54:26 -04:00
|
|
|
string get_output();
|
2016-11-25 07:55:15 -05:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-12-21 02:38:44 -05:00
|
|
|
|
|
|
|
protected:
|
2016-12-23 14:43:52 -05:00
|
|
|
bool input(string&& cmd);
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
private:
|
2016-11-30 15:03:28 -05:00
|
|
|
static constexpr auto DEFAULT_ICON = "ws-icon-default";
|
|
|
|
static constexpr auto DEFAULT_LABEL = "%icon% %name%";
|
2016-11-03 12:54:26 -04:00
|
|
|
static constexpr auto DEFAULT_MONITOR_LABEL = "%name%";
|
2016-11-30 15:03:28 -05:00
|
|
|
|
2016-11-03 12:54:26 -04:00
|
|
|
static constexpr auto TAG_LABEL_MONITOR = "<label-monitor>";
|
2016-06-14 23:32:35 -04:00
|
|
|
static constexpr auto TAG_LABEL_STATE = "<label-state>";
|
|
|
|
static constexpr auto TAG_LABEL_MODE = "<label-mode>";
|
2016-11-30 15:03:28 -05:00
|
|
|
|
2016-12-05 08:02:16 -05: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-14 23:32:35 -04:00
|
|
|
|
2016-10-11 03:25:32 -04:00
|
|
|
bspwm_util::connection_t m_subscriber;
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-03 12:54:26 -04:00
|
|
|
vector<unique_ptr<bspwm_monitor>> m_monitors;
|
|
|
|
|
2016-11-30 15:03:28 -05:00
|
|
|
map<mode, label_t> m_modelabels;
|
|
|
|
map<uint32_t, label_t> m_statelabels;
|
2016-11-03 12:54:26 -04:00
|
|
|
label_t m_monitorlabel;
|
2016-06-14 23:32:35 -04:00
|
|
|
iconset_t m_icons;
|
2016-11-12 07:37:07 -05:00
|
|
|
|
2016-12-14 01:45:29 -05:00
|
|
|
bool m_click{true};
|
|
|
|
bool m_scroll{true};
|
2016-12-14 11:18:20 -05:00
|
|
|
bool m_revscroll{true};
|
2016-12-14 01:45:29 -05:00
|
|
|
bool m_pinworkspaces{true};
|
|
|
|
string_util::hash_type m_hash{0U};
|
2016-11-03 12:54:26 -04:00
|
|
|
|
|
|
|
// used while formatting output
|
2016-12-14 01:45:29 -05:00
|
|
|
size_t m_index{0U};
|
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
|