dwm: Replace pin-tags with label-empty

If pin-tags is set, there is no format defined for tags that are not occupied.
However defining a format for unoccupied tags makes the pin-tags setting
redundant since then the label can just be set to empty to not show unoccupied
tags.

Following the above reasoning, the pin tags setting is removed, and
state_t::NONE is renamed to state_t::EMPTY. This way if a user wants to display
empty tags, they can specify the format, otherwise they can simply set the label
to an empty string.
This commit is contained in:
Mihir Lad 2020-07-20 00:29:43 -04:00
parent 7883ef82fe
commit a30a9b1e1b
3 changed files with 29 additions and 30 deletions

View File

@ -176,14 +176,12 @@ enable-click = false
; Available tokens:
; %name%
; Only show tags on the same output as the bar
;pin-tags = true
label-title = "%title%"
label-title = %title%
label-title-padding = 2
label-title-forefround = ${colors.primary}
label-title-maxlen = 30
label-layout = %layout%
label-layout-padding = 2
label-layout-foreground = #000
label-layout-background = ${colors.primary}
@ -199,16 +197,22 @@ label-unfocused = %name%
label-unfocused-padding = 2
; visible = Active tag on unfocused monitor
label-visible = %index%
label-visible = %name%
label-visible-background = ${self.label-focused-background}
label-visible-underline = ${self.label-focused-underline}
label-visible-padding = ${self.label-focused-padding}
; urgent = Tag with urgency hint set
label-urgent = %index%
label-urgent = %name%
label-urgent-background = ${colors.alert}
label-urgent-padding = 2
; empty = Tags with no windows assigned
; This can be set to an empty string to hide empty tags
label-empty = %name%
label-empty-background = ${colors.primary}
label-empty-padding = 2
; Separator in between workspaces
; label-separator = |

View File

@ -19,7 +19,7 @@ namespace modules {
URGENT, ///< Tag is urgent, overrides all below
UNFOCUSED, ///< Monitor is not selected, but tag is selected
VISIBLE, ///< Tag is not selected, but occupied
NONE ///< Tag is unoccupied and unselected
EMPTY ///< Tag is unoccupied and unselected
};
struct tag_t {
@ -67,7 +67,6 @@ namespace modules {
auto reconnect_dwm() -> bool;
bool m_click{true};
bool m_pin_tags{false};
const dwmipc::Monitor* m_active_mon = nullptr;
const dwmipc::Monitor* m_bar_mon = nullptr;

View File

@ -41,7 +41,7 @@ namespace modules {
m_state_labels.insert(
std::make_pair(state_t::URGENT, load_optional_label(m_conf, name(), "label-urgent", DEFAULT_STATE_LABEL)));
m_state_labels.insert(
std::make_pair(state_t::NONE, load_optional_label(m_conf, name(), "label-none", DEFAULT_STATE_LABEL)));
std::make_pair(state_t::EMPTY, load_optional_label(m_conf, name(), "label-empty", DEFAULT_STATE_LABEL)));
}
m_seperator_label = load_optional_label(m_conf, name(), "label-separator", "");
@ -55,7 +55,6 @@ namespace modules {
}
m_click = m_conf.get(name(), "enable-click", m_click);
m_pin_tags = m_conf.get(name(), "pin-tags", m_pin_tags);
try {
update_monitor_ref();
@ -141,8 +140,6 @@ namespace modules {
} else if (tag == TAG_LABEL_STATE) {
bool first = true;
for (const auto& tag : m_tags) {
// Print tags without state only if m_pin_tags
if ((tag.state == state_t::NONE && m_pin_tags) || (!m_pin_tags && tag.state != state_t::NONE)) {
// Don't insert separator before first tag
if (first) {
first = false;
@ -160,7 +157,6 @@ namespace modules {
builder->node(tag.label);
}
}
}
} else {
return false;
}
@ -202,7 +198,7 @@ namespace modules {
// Monitor unselected - Tag selected UNFOCUSED
// Tag unselected - Tag occupied - Tag non-urgent VISIBLE
// Tag unselected - Tag occupied - Tag urgent URGENT
// Tag unselected - Tag unoccupied PIN?
// Tag unselected - Tag unoccupied EMPTY
auto tag_state = m_bar_mon->tag_state;
bool is_mon_active = m_bar_mon == m_active_mon;
@ -221,7 +217,7 @@ namespace modules {
return state_t::VISIBLE;
}
return state_t::NONE;
return state_t::EMPTY;
}
void dwm_module::update_monitor_ref() {