blob: 89af45fa786f36aff7a7f4a6e1a35cfbe1fa0bd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/sh
# Layout-aware navigation for Hyprland
# Usage: layout-navigate <direction> [move]
# direction: next|prev
# move: if present, move window instead of focus
DIR="$1"
MOVE="$2"
ACTIVE_JSON=$(hyprctl activewindow -j)
FLOATING=$(echo "$ACTIVE_JSON" | jq -r '.floating')
WS_NAME=$(echo "$ACTIVE_JSON" | jq -r '.workspace.name')
LAYOUT=$(hyprctl getoption general:layout -j | jq -r '.str')
# If the active window is in a special workspace (scratchpad overlay) and we
# are navigating focus (not moving), hide the overlay first. layoutmsg/cyclenext
# cannot cross the overlay→regular boundary, so without this the $mod+J key
# gets trapped inside the scratchpad.
case "$WS_NAME" in
special:*)
if [ "$MOVE" != "move" ]; then
hyprctl dispatch togglespecialworkspace "${WS_NAME#special:}"
# Re-read state: focus has moved to the regular workspace.
ACTIVE_JSON=$(hyprctl activewindow -j)
FLOATING=$(echo "$ACTIVE_JSON" | jq -r '.floating')
fi
;;
esac
# If current window is floating, use cyclenext to reach tiled windows
if [ "$FLOATING" = "true" ] && [ "$MOVE" != "move" ]; then
if [ "$DIR" = "next" ]; then
hyprctl dispatch cyclenext tiled
else
hyprctl dispatch cyclenext prev tiled
fi
exit 0
fi
case "$LAYOUT" in
scrolling)
# J (next) goes left, K (prev) goes right
if [ "$MOVE" = "move" ]; then
if [ "$DIR" = "next" ]; then
hyprctl dispatch swapwindow l
else
hyprctl dispatch swapwindow r
fi
else
if [ "$DIR" = "next" ]; then
hyprctl dispatch layoutmsg focus l
else
hyprctl dispatch layoutmsg focus r
fi
fi
;;
*)
# master, dwindle, etc.
if [ "$MOVE" = "move" ]; then
if [ "$DIR" = "next" ]; then
hyprctl dispatch layoutmsg swapnext
else
hyprctl dispatch layoutmsg swapprev
fi
else
if [ "$DIR" = "next" ]; then
hyprctl dispatch layoutmsg cyclenext
else
hyprctl dispatch layoutmsg cycleprev
fi
fi
;;
esac
|