1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00
polybar/include/modules/bspwm.hpp

87 lines
2.1 KiB
C++
Raw Normal View History

#pragma once
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
#include "modules/meta.hpp"
#include "utils/bspwm.hpp"
2016-11-19 00:22:44 -05:00
POLYBAR_NS
2016-06-14 23:32:35 -04:00
namespace modules {
enum class state_ws {
2016-06-14 23:32:35 -04:00
WORKSPACE_NONE,
WORKSPACE_ACTIVE,
WORKSPACE_URGENT,
WORKSPACE_EMPTY,
WORKSPACE_OCCUPIED,
WORKSPACE_DIMMED, // used when the monitor is out of focus
WORKSPACE_DIMMED_ACTIVE,
WORKSPACE_DIMMED_URGENT,
WORKSPACE_DIMMED_EMPTY,
WORKSPACE_DIMMED_OCCUPIED
};
enum class state_mode {
2016-06-14 23:32:35 -04:00
MODE_NONE,
MODE_LAYOUT_MONOCLE,
MODE_LAYOUT_TILED,
MODE_STATE_FULLSCREEN,
MODE_STATE_FLOATING,
MODE_NODE_LOCKED,
MODE_NODE_STICKY,
MODE_NODE_PRIVATE
};
struct bspwm_monitor {
vector<pair<state_ws, label_t>> workspaces;
vector<label_t> modes;
2016-06-14 23:32:35 -04:00
label_t label;
string name;
bool focused = false;
2016-06-14 23:32:35 -04:00
};
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
class bspwm_module : public event_module<bspwm_module> {
public:
using event_module::event_module;
2016-11-02 15:22:45 -04:00
void setup();
void stop();
bool has_event();
bool update();
string get_output();
2016-11-02 15:22:45 -04:00
bool build(builder* builder, string tag) const;
bool handle_event(string cmd);
bool receive_events() const {
return true;
}
2016-06-14 23:32:35 -04:00
private:
static constexpr auto DEFAULT_WS_ICON = "ws-icon-default";
2016-06-14 23:32:35 -04:00
static constexpr auto DEFAULT_WS_LABEL = "%icon% %name%";
static constexpr auto DEFAULT_MONITOR_LABEL = "%name%";
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-11 13:55:37 -05:00
static constexpr auto EVENT_PREFIX = "bwm";
static constexpr auto EVENT_CLICK = "bwmf";
static constexpr auto EVENT_SCROLL_UP = "bwmn";
static constexpr auto EVENT_SCROLL_DOWN = "bwmp";
2016-06-14 23:32:35 -04:00
bspwm_util::connection_t m_subscriber;
2016-06-14 23:32:35 -04:00
vector<unique_ptr<bspwm_monitor>> m_monitors;
map<state_mode, label_t> m_modelabels;
map<state_ws, label_t> m_statelabels;
label_t m_monitorlabel;
2016-06-14 23:32:35 -04:00
iconset_t m_icons;
bool m_click = true;
bool m_scroll = true;
bool m_pinworkspaces = true;
2016-06-14 23:32:35 -04:00
unsigned long m_hash;
// used while formatting output
size_t m_index = 0;
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