diff options
| author | Robin Seger <pixelkhaos@gmail.com> | 2026-02-11 01:44:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-11 11:44:23 +1100 |
| commit | 2e22a21defc26b7a24fb0a01a0882f8d33e344be (patch) | |
| tree | c3a3db3911c2a6e962d9542953bebcf21ddb6330 | |
| parent | fix: bluetooth battery bar (#1153) (diff) | |
| download | caelestia-shell-2e22a21defc26b7a24fb0a01a0882f8d33e344be.tar.gz caelestia-shell-2e22a21defc26b7a24fb0a01a0882f8d33e344be.tar.bz2 caelestia-shell-2e22a21defc26b7a24fb0a01a0882f8d33e344be.zip | |
shortcuts: add special workspace cycle (#1158)
* [CI] chore: update flake
* [CI] chore: update flake
* [CI] chore: update flake
* [CI] chore: update flake
* shortcuts: special workspace cycle IPC, reopen last
* Moved implementation into Hypr service
---------
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
| -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 { |