-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautotiling.sh
More file actions
executable file
·22 lines (20 loc) · 874 Bytes
/
autotiling.sh
File metadata and controls
executable file
·22 lines (20 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Can be used instead of autotiling.py in sway, however found it less reliable than .py
#!/usr/bin/bash
handle() {
local event=$(swaymsg -t SUBSCRIBE "['window']");
local con_par=$(swaymsg -t get_tree | jq -r '[null,.]|recurse(.[1] as $parent|try (.[1].nodes[]|[($parent|del(.nodes)),.]) catch empty) | select(.[1].focused)')
local con=$(jq .[1] <<< $con_par)
local parent=$(jq .[0] <<< $con_par)
[[ $(jq any <<< $con) == false ]] && return;
[[ $(jq .fullscreen_mode <<< $con) != 0 ]] && return;
[[ $(jq .fullscreen_mode <<< $parent) != 0 ]] && return;
[[ $(jq .layout <<< $parent) == '"tabbed"' ]] && return;
local height=$(jq .rect.height <<< $con)
local width=$(jq .rect.width <<< $con)
local layout=$( [[ $height -gt $width ]] && echo "splitv" || echo "splith")
swaymsg $layout
echo $width $height $layout
}
while handle; do
sleep 0.1
done