feat(i3): Add workspace separator (#938)

Puts a label-separator node between workspaces on the bar. Since the
separator uses a label it can be configured like any other label

Closes: #929
This commit is contained in:
Patrick Ziegler 2018-01-07 01:19:02 +01:00 committed by NBonaparte
parent a7eb7b3576
commit d8414c6ec5
3 changed files with 23 additions and 0 deletions

View File

@ -155,6 +155,10 @@ label-urgent = %index%
label-urgent-background = ${module/bspwm.label-urgent-background} label-urgent-background = ${module/bspwm.label-urgent-background}
label-urgent-padding = ${module/bspwm.label-urgent-padding} label-urgent-padding = ${module/bspwm.label-urgent-padding}
; Separator in between workspaces
; label-separator = |
[module/mpd] [module/mpd]
type = internal/mpd type = internal/mpd
format-online = <label-song> <icon-prev> <icon-stop> <toggle> <icon-next> format-online = <label-song> <icon-prev> <icon-stop> <toggle> <icon-next>

View File

@ -76,6 +76,11 @@ namespace modules {
label_t m_modelabel; label_t m_modelabel;
bool m_modeactive{false}; bool m_modeactive{false};
/**
* Separator that is inserted in between workspaces
*/
label_t m_labelseparator;
bool m_click{true}; bool m_click{true};
bool m_scroll{true}; bool m_scroll{true};
bool m_revscroll{true}; bool m_revscroll{true};

View File

@ -52,6 +52,8 @@ namespace modules {
m_modelabel = load_optional_label(m_conf, name(), "label-mode", "%mode%"); m_modelabel = load_optional_label(m_conf, name(), "label-mode", "%mode%");
} }
m_labelseparator = load_optional_label(m_conf, name(), "label-separator", "");
m_icons = factory_util::shared<iconset>(); m_icons = factory_util::shared<iconset>();
m_icons->add(DEFAULT_WS_ICON, factory_util::shared<label>(m_conf.get(name(), DEFAULT_WS_ICON, ""s))); m_icons->add(DEFAULT_WS_ICON, factory_util::shared<label>(m_conf.get(name(), DEFAULT_WS_ICON, ""s)));
@ -171,7 +173,19 @@ namespace modules {
builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLL_UP); builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLL_UP);
} }
bool first = true;
for (auto&& ws : m_workspaces) { for (auto&& ws : m_workspaces) {
/*
* The separator should only be inserted in between the workspaces, so
* we insert it in front of all workspaces except the first one.
*/
if(first) {
first = false;
}
else if (*m_labelseparator) {
builder->node(m_labelseparator);
}
if (m_click) { if (m_click) {
builder->cmd(mousebtn::LEFT, string{EVENT_CLICK} + ws->name); builder->cmd(mousebtn::LEFT, string{EVENT_CLICK} + ws->name);
builder->node(ws->label); builder->node(ws->label);