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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#!/usr/bin/env bash
# ==================================================
# KoolDots (2026)
# Project URL: https://github.com/LinuxBeginnings
# License: GNU GPLv3
# SPDX-License-Identifier: GPL-3.0-or-later
# ==================================================
# for changing Hyprland Layouts (master, dwindle, scrolling, monocle) on the fly
notif="$HOME/.config/swaync/images/ja.png"
layouts=(master dwindle scrolling monocle)
get_layout() {
hyprctl -j getoption general:layout | jq -r '.str'
}
next_layout() {
local current="$1"
local i
for i in "${!layouts[@]}"; do
if [[ "${layouts[i]}" == "$current" ]]; then
echo "${layouts[((i + 1) % ${#layouts[@]})]}"
return
fi
done
echo "${layouts[0]}"
}
set_layout() {
local target="$1"
hyprctl keyword general:layout "$target"
hyprctl keyword unbind SUPER,j
hyprctl keyword unbind SUPER,k
hyprctl keyword unbind SUPER,left
hyprctl keyword unbind SUPER,right
hyprctl keyword unbind SUPER,up
hyprctl keyword unbind SUPER,down
hyprctl keyword unbind SUPER,O
case "$target" in
"dwindle")
hyprctl keyword bind SUPER,j,cyclenext
hyprctl keyword bind SUPER,k,cyclenext,prev
hyprctl keyword bind SUPER,left,cyclenext,prev
hyprctl keyword bind SUPER,up,cyclenext,prev
hyprctl keyword bind SUPER,right,cyclenext
hyprctl keyword bind SUPER,down,cyclenext
hyprctl keyword bind SUPER,O,layoutmsg,togglesplit
notify-send -e -u low -i "$notif" " Dwindle Layout"
;;
"scrolling")
hyprctl keyword bind SUPER,j,cyclenext
hyprctl keyword bind SUPER,k,cyclenext,prev
hyprctl keyword bind SUPER,left,cyclenext,prev
hyprctl keyword bind SUPER,up,cyclenext,prev
hyprctl keyword bind SUPER,right,cyclenext
hyprctl keyword bind SUPER,down,cyclenext
notify-send -e -u low -i "$notif" " Scrolling Layout"
;;
"monocle")
hyprctl keyword bind SUPER,j,layoutmsg,cyclenext
hyprctl keyword bind SUPER,k,layoutmsg,cycleprev
hyprctl keyword bind SUPER,left,layoutmsg,cycleprev
hyprctl keyword bind SUPER,up,layoutmsg,cycleprev
hyprctl keyword bind SUPER,right,layoutmsg,cyclenext
hyprctl keyword bind SUPER,down,layoutmsg,cyclenext
notify-send -e -u low -i "$notif" " Monocle Layout"
;;
"master")
hyprctl keyword bind SUPER,j,layoutmsg,cyclenext
hyprctl keyword bind SUPER,k,layoutmsg,cycleprev
hyprctl keyword bind SUPER,left,movefocus,l
hyprctl keyword bind SUPER,right,movefocus,r
hyprctl keyword bind SUPER,up,movefocus,u
hyprctl keyword bind SUPER,down,movefocus,d
notify-send -e -u low -i "$notif" " Master Layout"
;;
*)
hyprctl keyword bind SUPER,j,layoutmsg,cyclenext
hyprctl keyword bind SUPER,k,layoutmsg,cycleprev
hyprctl keyword bind SUPER,left,movefocus,l
hyprctl keyword bind SUPER,right,movefocus,r
hyprctl keyword bind SUPER,up,movefocus,u
hyprctl keyword bind SUPER,down,movefocus,d
echo "Unknown layout: $target" >&2
return 1
;;
esac
}
current="$(get_layout)"
arg="${1:-toggle}"
case "$arg" in
init)
set_layout "$current"
;;
toggle|next)
set_layout "$(next_layout "$current")"
;;
master|dwindle|scrolling|monocle)
set_layout "$arg"
;;
*)
echo "Usage: $(basename "$0") [toggle|next|init|master|dwindle|scrolling|monocle]" >&2
exit 1
;;
esac
|