diff options
| -rw-r--r-- | services/Hypr.qml | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/services/Hypr.qml b/services/Hypr.qml index a654fdd..a26c24d 100644 --- a/services/Hypr.qml +++ b/services/Hypr.qml @@ -34,6 +34,7 @@ Singleton { readonly property alias devices: extras.devices property bool hadKeyboard + property string lastSpecialWorkspace: "" signal configReloaded @@ -41,6 +42,39 @@ Singleton { Hyprland.dispatch(request); } + function cycleSpecialWorkspace(direction: string): void { + const openSpecials = workspaces.values.filter(w => w.name.startsWith("special:") && w.lastIpcObject.windows > 0); + + if (openSpecials.length === 0) + return; + + const activeSpecial = focusedMonitor.lastIpcObject.specialWorkspace.name ?? ""; + + if (!activeSpecial) { + if (lastSpecialWorkspace) { + const workspace = workspaces.values.find(w => w.name === lastSpecialWorkspace); + if (workspace && workspace.lastIpcObject.windows > 0) { + dispatch(`workspace ${lastSpecialWorkspace}`); + return; + } + } + dispatch(`workspace ${openSpecials[0].name}`); + return; + } + + const currentIndex = openSpecials.findIndex(w => w.name === activeSpecial); + let nextIndex = 0; + + if (currentIndex !== -1) { + if (direction === "next") + nextIndex = (currentIndex + 1) % openSpecials.length; + else + nextIndex = (currentIndex - 1 + openSpecials.length) % openSpecials.length; + } + + dispatch(`workspace ${openSpecials[nextIndex].name}`); + } + function monitorFor(screen: ShellScreen): HyprlandMonitor { return Hyprland.monitorFor(screen); } @@ -105,6 +139,18 @@ Singleton { } } + Connections { + target: root.focusedMonitor + + function onLastIpcObjectChanged(): void { + const specialName = root.focusedMonitor.lastIpcObject.specialWorkspace.name; + + if (specialName && specialName.startsWith("special:")) { + root.lastSpecialWorkspace = specialName; + } + } + } + FileView { id: kbLayoutFile @@ -144,6 +190,14 @@ Singleton { function refreshDevices(): void { extras.refreshDevices(); } + + function cycleSpecialWorkspace(direction: string): void { + root.cycleSpecialWorkspace(direction); + } + + function listSpecialWorkspaces(): string { + return root.workspaces.values.filter(w => w.name.startsWith("special:") && w.lastIpcObject.windows > 0).map(w => w.name).join("\n"); + } } CustomShortcut { |