1#!/usr/bin/env zsh
2
3STATE_FILE="$HOME/.local/state/wraith/cycle-special.state"
4
5# Get all special workspaces, sorted and exit if none found
6specials=(
7 ${(on)$(
8 hyprctl workspaces -j \
9 | jq -r '.[] | select(.name | startswith("special:")) | .name'
10 )}
11)
12
13(( ${#specials[@]} == 0 )) && exit 0
14
15# empty entry → means "hide"
16specials+=("")
17
18if [[ ! -f "$STATE_FILE" ]]; then
19 print -r -- "${specials[1]}" > "$STATE_FILE"
20fi
21
22current=$(<"$STATE_FILE")
23
24current_index=0
25for i in {1..${#specials[@]}}; do
26 if [[ "${specials[$i]}" == "$current" ]]; then
27 current_index=$i
28 break
29 fi
30done
31
32(( current_index == 0 )) && current_index=1
33
34next_index=$(( current_index + 1 ))
35(( next_index > ${#specials[@]} )) && next_index=1
36
37next="${specials[$next_index]}"
38
39if [[ -z "$next" ]]; then
40 hyprctl dispatch "hl.dsp.workspace.toggle_special('${current#*:}')"
41else
42 hyprctl dispatch "hl.dsp.focus({workspace = '$next' })"
43fi
44
45print -r -- "$next" > "$STATE_FILE"