diff options
author | xero <x@xero.nu> | 2017-01-22 23:22:55 -0500 |
---|---|---|
committer | xero <x@xero.nu> | 2017-01-22 23:22:55 -0500 |
commit | 5a4d4a06a287985fbf5b458056881d3d0a0c71aa (patch) | |
tree | 0daa8de87d60c396ca3dbadccbdfe735fc5f72d8 /wmutils/bin/tile.sh | |
parent | 4d6c6b497c3e4d5d6bd4e7728f42303f23120f27 (diff) | |
download | dotfiles_ascii-5a4d4a06a287985fbf5b458056881d3d0a0c71aa.tar.xz dotfiles_ascii-5a4d4a06a287985fbf5b458056881d3d0a0c71aa.zip |
add wmutils setup
Diffstat (limited to 'wmutils/bin/tile.sh')
-rwxr-xr-x | wmutils/bin/tile.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/wmutils/bin/tile.sh b/wmutils/bin/tile.sh new file mode 100755 index 0000000..2b89960 --- /dev/null +++ b/wmutils/bin/tile.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# z3bra - 2014 (c) wtfpl +# arrange windows in a tiled pattern + +# default values for gaps and master area +PANEL=${PANEL:-0} +GAP=${GAP:-20} +MASTER=${MASTER:-900} + +# get current window id and its borderwidth +PFW=$(pfw) +BW=$(wattr b $PFW) + +# get root window's size (beware, multi-head setups...) +ROOT=$(lsw -r) +SW=$(wattr w $ROOT) +SH=$(wattr h $ROOT) + +# get the number of windows to put in the stacking area +MAX=$(lsw|grep -v $PFW|wc -l) + +# calculate usable screen size (without borders and gaps) +SW=$((SW - GAP - 2*BW)) +SH=$((SH - GAP - 2*BW - PANEL)) + +Y=$((0 + GAP + PANEL)) +# put current window in master area +wtp $GAP $Y $((MASTER - GAP - 2*BW)) $((SH - GAP)) $PFW + +# and now, stack up all remaining windows on the right +X=$((MASTER + GAP)) +W=$((SW - MASTER - GAP)) +H=$((SH / MAX - GAP - 2*BW)) + +for wid in $(lsw|grep -v $PFW); do + wtp $X $Y $W $H $wid + Y=$((Y + H + GAP + 2*BW)) +done |