From a41b954216976381a937e2991a423c5a16e2750b Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:54:41 +1000 Subject: hypr: proper kb layout code --- services/Hypr.qml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'services') diff --git a/services/Hypr.qml b/services/Hypr.qml index 0f31453..249f5ae 100644 --- a/services/Hypr.qml +++ b/services/Hypr.qml @@ -22,8 +22,9 @@ Singleton { readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor readonly property int activeWsId: focusedWorkspace?.id ?? 1 - readonly property string kbLayout: kbLayoutFull.slice(0, 2).toLowerCase() + readonly property string kbLayout: kbMap.get(kbLayoutFull) ?? "??" property string kbLayoutFull: "?" + property var kbMap: new Map() function dispatch(request: string): void { Hyprland.dispatch(request); @@ -59,6 +60,23 @@ Singleton { } } + FileView { + id: kbLayoutFile + + path: Quickshell.env("CAELESTIA_XKB_RULES_PATH") || "/usr/share/X11/xkb/rules/base.lst" + onLoaded: { + const lines = text().match(/! layout\n([\s\S]*?)\n\n/)[1].split("\n"); + for (const line of lines) { + if (!line.trim() || line.trim().startsWith("!")) + continue; + + const match = line.match(/^\s*([a-z]{2,})\s+([a-zA-Z() ]+)$/); + if (match) + root.kbMap.set(match[2], match[1]); + } + } + } + Process { running: true command: ["hyprctl", "-j", "devices"] -- cgit v1.2.3-freya