From 5d1a3fe6a70c714866b3eeeea7f8346fbd04a3a1 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sat, 20 Sep 2025 13:02:18 +0200 Subject: [PATCH] hyprland xkb layout indicator: fix weird placement on vertical bar --- .../quickshell/ii/modules/bar/BarContent.qml | 16 +++++++++++----- .../modules/verticalBar/VerticalBarContent.qml | 17 ++++++++++++----- .config/quickshell/ii/services/HyprlandXkb.qml | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.config/quickshell/ii/modules/bar/BarContent.qml b/.config/quickshell/ii/modules/bar/BarContent.qml index 7e1e885c0..b17fda1e9 100644 --- a/.config/quickshell/ii/modules/bar/BarContent.qml +++ b/.config/quickshell/ii/modules/bar/BarContent.qml @@ -293,11 +293,17 @@ Item { // Bar content region active: HyprlandXkb.layoutCodes.length > 1 visible: active Layout.rightMargin: indicatorsRowLayout.realSpacing - sourceComponent: StyledText { - text: HyprlandXkb.currentLayoutCode - font.pixelSize: Appearance.font.pixelSize.small - color: rightSidebarButton.colText - animateChange: true + sourceComponent: Item { + implicitWidth: layoutCodeText.implicitWidth + StyledText { + id: layoutCodeText + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + text: HyprlandXkb.currentLayoutCode.split(":").join("\n") + font.pixelSize: text.includes("\n") ? Appearance.font.pixelSize.smaller : Appearance.font.pixelSize.small + color: rightSidebarButton.colText + animateChange: true + } } } MaterialSymbol { diff --git a/.config/quickshell/ii/modules/verticalBar/VerticalBarContent.qml b/.config/quickshell/ii/modules/verticalBar/VerticalBarContent.qml index bfcd0c6fb..5b4053e64 100644 --- a/.config/quickshell/ii/modules/verticalBar/VerticalBarContent.qml +++ b/.config/quickshell/ii/modules/verticalBar/VerticalBarContent.qml @@ -273,11 +273,18 @@ Item { // Bar content region active: HyprlandXkb.layoutCodes.length > 1 visible: active Layout.bottomMargin: indicatorsColumnLayout.realSpacing - sourceComponent: StyledText { - text: HyprlandXkb.currentLayoutCode - font.pixelSize: Appearance.font.pixelSize.small - color: rightSidebarButton.colText - animateChange: true + Layout.alignment: Qt.AlignHCenter + sourceComponent: Item { + implicitHeight: layoutCodeText.implicitHeight + StyledText { + id: layoutCodeText + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + text: HyprlandXkb.currentLayoutCode.split(":").join("\n") + font.pixelSize: text.includes("\n") ? Appearance.font.pixelSize.smaller : Appearance.font.pixelSize.small + color: rightSidebarButton.colText + animateChange: true + } } } MaterialSymbol { diff --git a/.config/quickshell/ii/services/HyprlandXkb.qml b/.config/quickshell/ii/services/HyprlandXkb.qml index 54c8f8f8b..1aa52ec54 100644 --- a/.config/quickshell/ii/services/HyprlandXkb.qml +++ b/.config/quickshell/ii/services/HyprlandXkb.qml @@ -57,7 +57,7 @@ Singleton { // Match variant: (whitespace + ) variant + whitespace + key + whitespace + description const matchVariant = line.match(/^\s*(\S+)\s+(\S+)\s+(.+)$/); if (matchVariant && matchVariant[3] === targetDescription) { - const complexLayout = matchVariant[2] + " " + matchVariant[1]; + const complexLayout = matchVariant[2] + matchVariant[1]; root.cachedLayoutCodes[matchVariant[3]] = complexLayout; root.currentLayoutCode = complexLayout; return true;