Skip to content

Commit a4241d7

Browse files
authored
Merge pull request Alexays#3823 from thetwistedlogic/feature/river-hide-vacant
Hide vacant tags config option on River
2 parents ab0acd0 + 8e0964a commit a4241d7

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

man/waybar-river-tags.5.scd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ Addressed by *river/tags*
3131
default: false ++
3232
Enables this module to consume all left over space dynamically.
3333

34+
*hide-vacant*: ++
35+
typeof: bool ++
36+
default: false ++
37+
Only show relevant tags: tags that are either focused or have a window on them.
38+
3439
# EXAMPLE
3540

3641
```

src/modules/river/tags.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,20 @@ bool Tags::handle_button_press(GdkEventButton *event_button, uint32_t tag) {
189189
}
190190

191191
void Tags::handle_focused_tags(uint32_t tags) {
192+
auto hide_vacant = config_["hide-vacant"].asBool();
192193
for (size_t i = 0; i < buttons_.size(); ++i) {
194+
bool visible = buttons_[i].is_visible();
195+
bool occupied = buttons_[i].get_style_context()->has_class("occupied");
196+
bool urgent = buttons_[i].get_style_context()->has_class("urgent");
193197
if ((1 << i) & tags) {
198+
if (hide_vacant && !visible) {
199+
buttons_[i].set_visible(true);
200+
}
194201
buttons_[i].get_style_context()->add_class("focused");
195202
} else {
203+
if (hide_vacant && !(occupied || urgent)) {
204+
buttons_[i].set_visible(false);
205+
}
196206
buttons_[i].get_style_context()->remove_class("focused");
197207
}
198208
}
@@ -205,20 +215,40 @@ void Tags::handle_view_tags(struct wl_array *view_tags) {
205215
for (; view_tag < end; ++view_tag) {
206216
tags |= *view_tag;
207217
}
218+
auto hide_vacant = config_["hide-vacant"].asBool();
208219
for (size_t i = 0; i < buttons_.size(); ++i) {
220+
bool visible = buttons_[i].is_visible();
221+
bool focused = buttons_[i].get_style_context()->has_class("focused");
222+
bool urgent = buttons_[i].get_style_context()->has_class("urgent");
209223
if ((1 << i) & tags) {
224+
if (hide_vacant && !visible) {
225+
buttons_[i].set_visible(true);
226+
}
210227
buttons_[i].get_style_context()->add_class("occupied");
211228
} else {
229+
if (hide_vacant && !(focused || urgent)) {
230+
buttons_[i].set_visible(false);
231+
}
212232
buttons_[i].get_style_context()->remove_class("occupied");
213233
}
214234
}
215235
}
216236

217237
void Tags::handle_urgent_tags(uint32_t tags) {
238+
auto hide_vacant = config_["hide-vacant"].asBool();
218239
for (size_t i = 0; i < buttons_.size(); ++i) {
240+
bool visible = buttons_[i].is_visible();
241+
bool occupied = buttons_[i].get_style_context()->has_class("occupied");
242+
bool focused = buttons_[i].get_style_context()->has_class("focused");
219243
if ((1 << i) & tags) {
244+
if (hide_vacant && !visible) {
245+
buttons_[i].set_visible(true);
246+
}
220247
buttons_[i].get_style_context()->add_class("urgent");
221248
} else {
249+
if (hide_vacant && !(occupied || focused)) {
250+
buttons_[i].set_visible(false);
251+
}
222252
buttons_[i].get_style_context()->remove_class("urgent");
223253
}
224254
}

0 commit comments

Comments
 (0)