From 0859d752560ad6cb8b99de8bdccc034eeee9f988 Mon Sep 17 00:00:00 2001 From: nrand Date: Thu, 18 Sep 2025 15:03:09 +0300 Subject: [PATCH] bar: fixed kb layout+variant display in top right --- .../quickshell/ii/services/HyprlandXkb.qml | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.config/quickshell/ii/services/HyprlandXkb.qml b/.config/quickshell/ii/services/HyprlandXkb.qml index cace0d29e..2d9d408e2 100644 --- a/.config/quickshell/ii/services/HyprlandXkb.qml +++ b/.config/quickshell/ii/services/HyprlandXkb.qml @@ -46,13 +46,24 @@ Singleton { if (!line.trim() || line.trim().startsWith('!')) return false; - // Match: key + whitespace + description - const match = line.match(/^\s*(\S+)\s+(.+)$/); - if (match && match[2] === targetDescription) { - root.cachedLayoutCodes[match[2]] = match[1]; - root.currentLayoutCode = match[1]; + // Match layout: (whitespace + ) key + whitespace + description + const matchLayout = line.match(/^\s*(\S+)\s+(.+)$/); + if (matchLayout && matchLayout[2] === targetDescription) { + root.cachedLayoutCodes[matchLayout[2]] = matchLayout[1]; + root.currentLayoutCode = matchLayout[1]; return true; } + + // 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]; + root.cachedLayoutCodes[matchVariant[3]] = complexLayout; + root.currentLayourCode = complexLayout; + return true; + } + + return false; }); // console.log("[HyprlandXkb] Found line:", foundLine); // console.log("[HyprlandXkb] Layout:", root.currentLayoutName, "| Code:", root.currentLayoutCode);