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:
parent
7883ef82fe
commit
a30a9b1e1b
16
config.cmake
16
config.cmake
@ -176,14 +176,12 @@ enable-click = false
|
|||||||
; Available tokens:
|
; Available tokens:
|
||||||
; %name%
|
; %name%
|
||||||
|
|
||||||
; Only show tags on the same output as the bar
|
label-title = %title%
|
||||||
;pin-tags = true
|
|
||||||
|
|
||||||
label-title = "%title%"
|
|
||||||
label-title-padding = 2
|
label-title-padding = 2
|
||||||
label-title-forefround = ${colors.primary}
|
label-title-forefround = ${colors.primary}
|
||||||
label-title-maxlen = 30
|
label-title-maxlen = 30
|
||||||
|
|
||||||
|
label-layout = %layout%
|
||||||
label-layout-padding = 2
|
label-layout-padding = 2
|
||||||
label-layout-foreground = #000
|
label-layout-foreground = #000
|
||||||
label-layout-background = ${colors.primary}
|
label-layout-background = ${colors.primary}
|
||||||
@ -199,16 +197,22 @@ label-unfocused = %name%
|
|||||||
label-unfocused-padding = 2
|
label-unfocused-padding = 2
|
||||||
|
|
||||||
; visible = Active tag on unfocused monitor
|
; visible = Active tag on unfocused monitor
|
||||||
label-visible = %index%
|
label-visible = %name%
|
||||||
label-visible-background = ${self.label-focused-background}
|
label-visible-background = ${self.label-focused-background}
|
||||||
label-visible-underline = ${self.label-focused-underline}
|
label-visible-underline = ${self.label-focused-underline}
|
||||||
label-visible-padding = ${self.label-focused-padding}
|
label-visible-padding = ${self.label-focused-padding}
|
||||||
|
|
||||||
; urgent = Tag with urgency hint set
|
; urgent = Tag with urgency hint set
|
||||||
label-urgent = %index%
|
label-urgent = %name%
|
||||||
label-urgent-background = ${colors.alert}
|
label-urgent-background = ${colors.alert}
|
||||||
label-urgent-padding = 2
|
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
|
; Separator in between workspaces
|
||||||
; label-separator = |
|
; label-separator = |
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace modules {
|
|||||||
URGENT, ///< Tag is urgent, overrides all below
|
URGENT, ///< Tag is urgent, overrides all below
|
||||||
UNFOCUSED, ///< Monitor is not selected, but tag is selected
|
UNFOCUSED, ///< Monitor is not selected, but tag is selected
|
||||||
VISIBLE, ///< Tag is not selected, but occupied
|
VISIBLE, ///< Tag is not selected, but occupied
|
||||||
NONE ///< Tag is unoccupied and unselected
|
EMPTY ///< Tag is unoccupied and unselected
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tag_t {
|
struct tag_t {
|
||||||
@ -67,7 +67,6 @@ namespace modules {
|
|||||||
auto reconnect_dwm() -> bool;
|
auto reconnect_dwm() -> bool;
|
||||||
|
|
||||||
bool m_click{true};
|
bool m_click{true};
|
||||||
bool m_pin_tags{false};
|
|
||||||
|
|
||||||
const dwmipc::Monitor* m_active_mon = nullptr;
|
const dwmipc::Monitor* m_active_mon = nullptr;
|
||||||
const dwmipc::Monitor* m_bar_mon = nullptr;
|
const dwmipc::Monitor* m_bar_mon = nullptr;
|
||||||
|
@ -41,7 +41,7 @@ namespace modules {
|
|||||||
m_state_labels.insert(
|
m_state_labels.insert(
|
||||||
std::make_pair(state_t::URGENT, load_optional_label(m_conf, name(), "label-urgent", DEFAULT_STATE_LABEL)));
|
std::make_pair(state_t::URGENT, load_optional_label(m_conf, name(), "label-urgent", DEFAULT_STATE_LABEL)));
|
||||||
m_state_labels.insert(
|
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", "");
|
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_click = m_conf.get(name(), "enable-click", m_click);
|
||||||
m_pin_tags = m_conf.get(name(), "pin-tags", m_pin_tags);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
update_monitor_ref();
|
update_monitor_ref();
|
||||||
@ -141,8 +140,6 @@ namespace modules {
|
|||||||
} else if (tag == TAG_LABEL_STATE) {
|
} else if (tag == TAG_LABEL_STATE) {
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (const auto& tag : m_tags) {
|
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
|
// Don't insert separator before first tag
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
@ -160,7 +157,6 @@ namespace modules {
|
|||||||
builder->node(tag.label);
|
builder->node(tag.label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -202,7 +198,7 @@ namespace modules {
|
|||||||
// Monitor unselected - Tag selected UNFOCUSED
|
// Monitor unselected - Tag selected UNFOCUSED
|
||||||
// Tag unselected - Tag occupied - Tag non-urgent VISIBLE
|
// Tag unselected - Tag occupied - Tag non-urgent VISIBLE
|
||||||
// Tag unselected - Tag occupied - Tag urgent URGENT
|
// 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;
|
auto tag_state = m_bar_mon->tag_state;
|
||||||
bool is_mon_active = m_bar_mon == m_active_mon;
|
bool is_mon_active = m_bar_mon == m_active_mon;
|
||||||
@ -221,7 +217,7 @@ namespace modules {
|
|||||||
return state_t::VISIBLE;
|
return state_t::VISIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return state_t::NONE;
|
return state_t::EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dwm_module::update_monitor_ref() {
|
void dwm_module::update_monitor_ref() {
|
||||||
|
Loading…
Reference in New Issue
Block a user