dots

Personal dotfiles
git clone git://git.gormless.xyz/dots.git
Log | Files | Refs

tile (906B)


      1 #!/bin/sh
      2 #
      3 # z3bra - 2014 (c) wtfpl
      4 # arrange windows in a tiled pattern
      5 
      6 # get root window's size (beware, multi-head setups...)
      7 ROOT=$(lswin -r)
      8 SW=$(wattr w $ROOT)
      9 SH=$(wattr h $ROOT)
     10 
     11 # default values for gaps and master area
     12 PANEL=${PANEL:-0}
     13 GAP=${GAP:-20}
     14 MASTER=$((SW / 2))
     15 
     16 # get current window id and its borderwidth
     17 PFW=$(pfw)
     18 BW=$(wattr b $PFW)
     19 
     20 # get the number of windows to put in the stacking area
     21 MAX=$(lswin|grep -v $PFW|wc -l)
     22 
     23 # calculate usable screen size (without borders and gaps)
     24 SW=$((SW - GAP - 2*BW))
     25 SH=$((SH - GAP - PANEL))
     26 
     27 Y=$((0 + GAP + PANEL))
     28 # put current window in master area
     29 wtp $GAP $Y $((MASTER - GAP - 2*BW)) $((SH - GAP - 2*BW)) $PFW
     30 
     31 # and now, stack up all remaining windows on the right
     32 X=$((MASTER + GAP))
     33 W=$((SW - MASTER - GAP))
     34 H=$((SH / MAX - GAP - 2*BW))
     35 
     36 for wid in $(lswin|grep -v $PFW); do
     37     wtp $X $Y $W $H $wid
     38     Y=$((Y + H + GAP + 2*BW))
     39 done