From b68f0bae14227a4d65303654fef4801c76f57ac0 Mon Sep 17 00:00:00 2001 From: Ezekiel Gonzales <141341590+notsoeazy@users.noreply.github.com> Date: Sun, 15 Mar 2026 15:55:55 +0800 Subject: bar/activewindow: add compact option (#1201) Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> --- modules/bar/components/ActiveWindow.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'modules/bar/components') diff --git a/modules/bar/components/ActiveWindow.qml b/modules/bar/components/ActiveWindow.qml index 0c9b21e..b21c525 100644 --- a/modules/bar/components/ActiveWindow.qml +++ b/modules/bar/components/ActiveWindow.qml @@ -13,6 +13,18 @@ Item { required property Brightness.Monitor monitor property color colour: Colours.palette.m3primary + readonly property string windowTitle: Hypr.activeToplevel?.title ?? qsTr("Desktop") + + function getCompactName() { + if (!root.windowTitle || root.windowTitle === qsTr("Desktop")) + return qsTr("Desktop"); + // " - " (standard hyphen), " — " (em dash), " – " (en dash) + const parts = root.windowTitle.split(/\s+[\-\u2013\u2014]\s+/); + if (parts.length > 1) + return parts[parts.length - 1].trim(); + return root.windowTitle; + } + readonly property int maxHeight: { const otherModules = bar.children.filter(c => c.id && c.item !== this && c.id !== "spacer"); const otherHeight = otherModules.reduce((acc, curr) => acc + (curr.item.nonAnimHeight ?? curr.height), 0); @@ -46,7 +58,7 @@ Item { TextMetrics { id: metrics - text: Hypr.activeToplevel?.title ?? qsTr("Desktop") + text: Config.bar.activeWindow.compact ? root.getCompactName() : root.windowTitle font.pointSize: Appearance.font.size.smaller font.family: Appearance.font.family.mono elide: Qt.ElideRight -- cgit v1.2.3-freya