Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dwl/tags: add hide-vacant option #3925

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/modules/dwl/tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
};

Expand Down
5 changes: 5 additions & 0 deletions man/waybar-dwl-tags.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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 ++
Expand Down
10 changes: 10 additions & 0 deletions src/modules/dwl/tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 */