-
Notifications
You must be signed in to change notification settings - Fork 0
/
autotile
executable file
·69 lines (54 loc) · 1.48 KB
/
autotile
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
#!/bin/sh
#
# autotile
usage() {
base=$(basename "$0")
cat >&2 << EOF
Usage:
$base [tile method] [monitor]
EOF
[ $# -eq 0 ] || exit "$1"
}
main() {
. fwmrc
wmgaps
case "$1" in
-g|--grid|grid) METHOD="grid" ;;
-s|--split|split) METHOD="split" ;;
-v|--vert|vert) METHOD="vert" ;;
-l|--left|left) METHOD="left" ;;
-r|--right|right) METHOD="right" ;;
-b|--browse|browse) METHOD="browse" ;;
-h|--help|help) usage 0 ;;
*) usage 1 ;;
esac
if mattr "$2"; then
SCR="$2"
else
printf '%s\n\n' "$2 is not a connected screen."
usage 1
fi
# init var
nWindowsOld=0
while :; do
nWindows="$(listwindows "$SEC" | wc -l)"
# compare number of current windows vs number of old windows
if [ "$nWindows" -ne "$nWindowsOld" ]; then
# exceptions to autotiling
prev="$(lsw | tail -n 1)"
case "$(atomx WM_CLASS "$prev")" in
python3|DiscordCanary) continue ;;
esac
# kill xmmv only when a window is dragged to the screen
if [ "$nWindows" -gt "$nWindowsOld" ]; then
pkill xmmv 2> /dev/null
fi
# autotile given monitor
tile "$METHOD" "$SCR"
# re-adjust counter
nWindowsOld="$nWindows"
fi
sleep 0.10
done
}
main "$@"