wlr/taskbar: add truncate to ellipsize long button text

This commit is contained in:
Maik Broemme
2026-07-04 01:16:45 +02:00
committed by Alex
parent e36824e7be
commit 7a84583a76
2 changed files with 16 additions and 0 deletions
+5
View File
@@ -84,6 +84,11 @@ Addressed by *wlr/taskbar*
default: false ++
If set to true, task buttons stretch to fill the available space in the taskbar and long titles are ellipsized to fit. Only takes effect on a horizontal bar; on a vertical bar the buttons keep their content-based size. If set to false, buttons are sized to their content.
*truncate*: ++
typeof: bool ++
default: false ++
If set to true, the task button text will be ellipsized (truncated with …) when the available button width is smaller than the label text.
*on-click*: ++
typeof: string ++
The action which should be triggered when clicking on the application button with the left mouse button.
+11
View File
@@ -138,6 +138,17 @@ Task::Task(const waybar::Bar& bar, const Json::Value& config, Taskbar* tbar,
content_.show();
button.add(content_);
// Apply optional label truncation (ellipsize).
if (config_["truncate"].isBool() && config_["truncate"].asBool()) {
text_before_.set_single_line_mode(true);
text_before_.set_ellipsize(Pango::ELLIPSIZE_END);
text_before_.set_line_wrap(false);
text_after_.set_single_line_mode(true);
text_after_.set_ellipsize(Pango::ELLIPSIZE_END);
text_after_.set_line_wrap(false);
}
format_before_.clear();
format_after_.clear();