dwl/tags: add hide-vacant option

This commit is contained in:
Alex Denes
2025-02-08 03:53:28 +00:00
parent c32d5e3883
commit 807208cba8
3 changed files with 16 additions and 0 deletions
+1
View File
@@ -28,6 +28,7 @@ class Tags : public waybar::AModule {
const waybar::Bar &bar_;
Gtk::Box box_;
std::vector<Gtk::Button> buttons_;
bool hide_vacant_;
struct zdwl_ipc_output_v2 *output_status_;
};
+5
View File
@@ -21,6 +21,11 @@ Addressed by *dwl/tags*
typeof: array ++
The label to display for each tag.
*hide-vacant*: ++
typeof: bool ++
default: false ++
If set to true, tags without clients and that are not active will be hidden.
*disable-click*: ++
typeof: bool ++
default: false ++
+10
View File
@@ -94,7 +94,11 @@ Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &con
seat_{nullptr},
bar_(bar),
box_{bar.orientation, 0},
hide_vacant_(false),
output_status_{nullptr} {
if (config_["hide-vacant"].asBool()) {
hide_vacant_ = config_["hide-vacant"].asBool();
}
struct wl_display *display = Client::inst()->wl_display;
struct wl_registry *registry = wl_display_get_registry(display);
@@ -198,6 +202,12 @@ void Tags::handle_view_tags(uint32_t tag, uint32_t state, uint32_t clients, uint
} else {
button.get_style_context()->remove_class("urgent");
}
if (hide_vacant_ && !clients && !(state & TAG_ACTIVE)) {
button.set_visible(false);
} else {
button.set_visible(true);
}
}
} /* namespace waybar::modules::dwl */