summaryrefslogtreecommitdiff
path: root/dotfiles/hyprland/.local/bin/layout-navigate
blob: ec2f659627231c172b188eea5b76cda1fec004ab (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
#!/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"
LAYOUT=$(hyprctl getoption general:layout -j | jq -r '.str')

case "$LAYOUT" in
    scrolling)
        if [ "$MOVE" = "move" ]; then
            if [ "$DIR" = "next" ]; then
                hyprctl dispatch layoutmsg movewindowto r
            else
                hyprctl dispatch layoutmsg movewindowto l
            fi
        else
            if [ "$DIR" = "next" ]; then
                hyprctl dispatch layoutmsg focus r
            else
                hyprctl dispatch layoutmsg focus l
            fi
        fi
        ;;
    hy3)
        if [ "$MOVE" = "move" ]; then
            if [ "$DIR" = "next" ]; then
                hyprctl dispatch hy3:movewindow r
            else
                hyprctl dispatch hy3:movewindow l
            fi
        else
            if [ "$DIR" = "next" ]; then
                hyprctl dispatch hy3:movefocus r
            else
                hyprctl dispatch hy3:movefocus l
            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