commit dcc2316

hovercats  ·  2022-03-03 20:09:17 +0000 UTC
parent 5e0dd79
add tile.sh
2 files changed,  +42, -0
M README
M README
+1, -0
1@@ -19,5 +19,6 @@ The following scripts require(/is used with) wmutils[0] to work:
2   - fullscreen.sh
3     - depend on focus.sh
4   - focus.sh
5+  - tile.sh
6 
7 [0] https://github.com/wmutils/core
+41, -0
 1@@ -0,0 +1,41 @@
 2+#!/bin/sh
 3+#
 4+# z3bra - 2014 (c) wtfpl
 5+# arrange windows in a tiled pattern
 6+
 7+# default values for gaps and master area
 8+PANEL=${PANEL:-0}
 9+GAP=${GAP:-20}
10+MASTER=${MASTER:-900}
11+
12+# get current window id and its borderwidth
13+PFW=$(pfw)
14+BW=$(wattr b "$PFW")
15+
16+# get root window's size (beware, multi-head setups...)
17+ROOT=$(lsw -r)
18+SW=$(wattr w "$ROOT")
19+SH=$(wattr h "$ROOT")
20+
21+# get the number of windows to put in the stacking area
22+# using grep -c here does no give us the correct behavior.
23+# shellcheck disable=2126
24+MAX=$(lsw|grep -v "$PFW"|wc -l)
25+
26+# calculate usable screen size (without borders and gaps)
27+SW=$((SW - GAP - 2*BW))
28+SH=$((SH - GAP - PANEL))
29+
30+Y=$((0 + GAP + PANEL))
31+# put current window in master area
32+wtp "$GAP" $Y $((MASTER - GAP - 2*BW)) $((SH - GAP - 2*BW)) "$PFW"
33+
34+# and now, stack up all remaining windows on the right
35+X=$((MASTER + GAP))
36+W=$((SW - MASTER - GAP))
37+H=$((SH / MAX - GAP - 2*BW))
38+
39+for wid in $(lsw|grep -v "$PFW"); do
40+    wtp $X $Y $W $H "$wid"
41+    Y=$((Y + H + GAP + 2*BW))
42+done