diff options
Diffstat (limited to 'services/Hypr.qml')
| -rw-r--r-- | services/Hypr.qml | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/services/Hypr.qml b/services/Hypr.qml index cd68d72..7a17212 100644 --- a/services/Hypr.qml +++ b/services/Hypr.qml @@ -3,6 +3,7 @@ pragma Singleton import qs.components.misc import qs.config import Caelestia +import Caelestia.Internal import Quickshell import Quickshell.Hyprland import Quickshell.Io @@ -20,16 +21,24 @@ Singleton { readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor readonly property int activeWsId: focusedWorkspace?.id ?? 1 - property var keyboard + readonly property HyprKeyboard keyboard: extras.devices.keyboards.find(kb => kb.main) ?? null readonly property bool capsLock: keyboard?.capsLock ?? false readonly property bool numLock: keyboard?.numLock ?? false readonly property string defaultKbLayout: keyboard?.layout.split(",")[0] ?? "??" - readonly property string kbLayoutFull: keyboard?.active_keymap ?? "Unknown" + readonly property string kbLayoutFull: keyboard?.activeKeymap ?? "Unknown" readonly property string kbLayout: kbMap.get(kbLayoutFull) ?? "??" readonly property var kbMap: new Map() + readonly property alias extras: extras + readonly property alias options: extras.options + readonly property alias devices: extras.devices + signal configReloaded + function message(message: string): void { + extras.message(message); + } + function dispatch(request: string): void { Hyprland.dispatch(request); } @@ -68,9 +77,7 @@ Singleton { if (n === "configreloaded") { root.configReloaded(); - setDynamicConfsProc.running = true; - } else if (n === "activelayout") { - devicesProc.running = true; + extras.message("[[BATCH]]keyword bindln ,Caps_Lock,global,caelestia:refreshDevices;keyword bindln ,Num_Lock,global,caelestia:refreshDevices"); } else if (["workspace", "moveworkspace", "activespecial", "focusedmon"].includes(n)) { Hyprland.refreshWorkspaces(); Hyprland.refreshMonitors(); @@ -104,35 +111,22 @@ Singleton { } } - Process { - id: devicesProc - - running: true - command: ["hyprctl", "-j", "devices"] - stdout: StdioCollector { - onStreamFinished: root.keyboard = JSON.parse(text).keyboards.find(k => k.main) - } - } - - Process { - id: setDynamicConfsProc - - running: true - command: ["hyprctl", "--batch", "keyword bindln ,Caps_Lock,global,caelestia:reloadDevices;keyword bindln ,Num_Lock,global,caelestia:reloadDevices"] - } - IpcHandler { target: "hypr" - function reloadDevices(): void { - devicesProc.running = true; + function refreshDevices(): void { + extras.refreshDevices(); } } CustomShortcut { - name: "reloadDevices" + name: "refreshDevices" description: "Reload devices" - onPressed: devicesProc.running = true - onReleased: devicesProc.running = true + onPressed: extras.refreshDevices() + onReleased: extras.refreshDevices() + } + + HyprExtras { + id: extras } } |