feat(bspwm): Support for multi monitors listing

- All available workspaces can now be listed, grouped
by monitor, by setting the module config `pin-workspaces`
to false

- Adds a new format tag <label-monitor>

- Treat <label-mode> as a normal format tag
This commit is contained in:
Michael Carlberg 2016-11-03 17:54:26 +01:00
parent 12a64bd3d6
commit 5f21d7d440
2 changed files with 161 additions and 95 deletions
include/modules

View file

@ -8,13 +8,15 @@
LEMONBUDDY_NS
namespace modules {
enum class bspwm_flag {
enum class state_ws {
WORKSPACE_NONE,
WORKSPACE_ACTIVE,
WORKSPACE_URGENT,
WORKSPACE_EMPTY,
WORKSPACE_OCCUPIED,
WORKSPACE_DIMMED, // used when the monitor is out of focus
};
enum class state_mode {
MODE_NONE,
MODE_LAYOUT_MONOCLE,
MODE_LAYOUT_TILED,
@ -25,20 +27,14 @@ namespace modules {
MODE_NODE_PRIVATE
};
struct bspwm_workspace {
bspwm_flag flag;
struct bspwm_monitor {
vector<pair<state_ws, label_t>> workspaces;
vector<label_t> modes;
label_t label;
bspwm_workspace(bspwm_flag flag, label_t&& label)
: flag(flag), label(forward<decltype(label)>(label)) {}
operator bool() {
return label && *label;
}
string name;
bool focused = false;
};
using bspwm_workspace_t = unique_ptr<bspwm_workspace>;
class bspwm_module : public event_module<bspwm_module> {
public:
using event_module::event_module;
@ -47,6 +43,7 @@ namespace modules {
void stop();
bool has_event();
bool update();
string get_output();
bool build(builder* builder, string tag) const;
bool handle_event(string cmd);
bool receive_events() const;
@ -54,19 +51,26 @@ namespace modules {
private:
static constexpr auto DEFAULT_WS_ICON = "ws-icon-default";
static constexpr auto DEFAULT_WS_LABEL = "%icon% %name%";
static constexpr auto DEFAULT_MONITOR_LABEL = "%name%";
static constexpr auto TAG_LABEL_MONITOR = "<label-monitor>";
static constexpr auto TAG_LABEL_STATE = "<label-state>";
static constexpr auto TAG_LABEL_MODE = "<label-mode>";
static constexpr auto EVENT_CLICK = "bwm";
bspwm_util::connection_t m_subscriber;
map<bspwm_flag, label_t> m_modelabels;
map<bspwm_flag, label_t> m_statelabels;
vector<bspwm_workspace_t> m_workspaces;
vector<label_t> m_modes;
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;
iconset_t m_icons;
bool m_pinworkspaces = true;
string m_monitor;
unsigned long m_hash;
// used while formatting output
size_t m_index = 0;
};
}