From a238c33fd06358af414c0f7a35a4d682242f79c1 Mon Sep 17 00:00:00 2001 From: dodaars Date: Sun, 21 Sep 2025 23:54:12 +0200 Subject: [PATCH 1/2] A simple function to slice keyboard variants to avoid overflow of text when using vertical bars I added a function that slices keyboard variants to be at most 4 characters long to avoid text overflow, especially when you set the bar to be vertical. --- .../quickshell/ii/modules/bar/HyprlandXkbIndicator.qml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.config/quickshell/ii/modules/bar/HyprlandXkbIndicator.qml b/.config/quickshell/ii/modules/bar/HyprlandXkbIndicator.qml index 3e85b829b..ed00cd532 100644 --- a/.config/quickshell/ii/modules/bar/HyprlandXkbIndicator.qml +++ b/.config/quickshell/ii/modules/bar/HyprlandXkbIndicator.qml @@ -6,10 +6,16 @@ import qs.modules.common.widgets Loader { id: root property bool vertical: false - active: HyprlandXkb.layoutCodes.length > 1 visible: active + function abbreviateLayoutCode(fullCode) { + return fullCode.split(':').map(layout => { + const baseLayout = layout.split('-')[0]; + return baseLayout.length > 4 ? baseLayout.slice(0, 4) : baseLayout; + }).join('\n'); + } + sourceComponent: Item { implicitWidth: root.vertical ? null : layoutCodeText.implicitWidth implicitHeight: root.vertical ? layoutCodeText.implicitHeight : null @@ -18,7 +24,7 @@ Loader { id: layoutCodeText anchors.centerIn: parent horizontalAlignment: Text.AlignHCenter - text: HyprlandXkb.currentLayoutCode.split(":").join("\n") + text: abbreviateLayoutCode(HyprlandXkb.currentLayoutCode) font.pixelSize: text.includes("\n") ? Appearance.font.pixelSize.smallie : Appearance.font.pixelSize.small color: rightSidebarButton.colText animateChange: true From 44cbd025f4aadf5e7f56c1aa426952be4de927e3 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 28 Sep 2025 08:25:48 +0200 Subject: [PATCH 2/2] correct indentation, remove unnecessary check --- .../quickshell/ii/modules/bar/HyprlandXkbIndicator.qml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.config/quickshell/ii/modules/bar/HyprlandXkbIndicator.qml b/.config/quickshell/ii/modules/bar/HyprlandXkbIndicator.qml index ed00cd532..c4dc11083 100644 --- a/.config/quickshell/ii/modules/bar/HyprlandXkbIndicator.qml +++ b/.config/quickshell/ii/modules/bar/HyprlandXkbIndicator.qml @@ -10,11 +10,11 @@ Loader { visible: active function abbreviateLayoutCode(fullCode) { - return fullCode.split(':').map(layout => { - const baseLayout = layout.split('-')[0]; - return baseLayout.length > 4 ? baseLayout.slice(0, 4) : baseLayout; - }).join('\n'); - } + return fullCode.split(':').map(layout => { + const baseLayout = layout.split('-')[0]; + return baseLayout.slice(0, 4); + }).join('\n'); + } sourceComponent: Item { implicitWidth: root.vertical ? null : layoutCodeText.implicitWidth