diff options
| -rw-r--r-- | nix/default.nix | 4 | ||||
| -rw-r--r-- | services/Hypr.qml | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/nix/default.nix b/nix/default.nix index 29a93cb..1f27491 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -33,6 +33,7 @@ wayland, wayland-protocols, wayland-scanner, + xkeyboard-config, caelestia-cli, withCli ? false, extraRuntimeDeps ? [], @@ -120,7 +121,7 @@ in src = ./..; nativeBuildInputs = [gcc makeWrapper qt6.wrapQtAppsHook]; - buildInputs = [quickshell beatDetector idleInhibitor qt6.qtbase]; + buildInputs = [quickshell beatDetector idleInhibitor xkeyboard-config qt6.qtbase]; propagatedBuildInputs = runtimeDeps; patchPhase = '' @@ -137,6 +138,7 @@ in --set FONTCONFIG_FILE "${fontconfig}" \ --set CAELESTIA_BD_PATH ${beatDetector}/bin/beat_detector \ --set CAELESTIA_II_PATH ${idleInhibitor}/bin/inhibit_idle \ + --set CAELESTIA_XKB_RULES_PATH ${xkeyboard-config}/share/xkeyboard-config-2/rules/base.lst \ --add-flags "-p $out/share/caelestia-shell" ln -sf ${beatDetector}/bin/beat_detector $out/bin 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"] |