#!/bin/rc # wm/tile - tile windows # usage: wm/tile # # note: incompatible with riow(1) and init/wm # gather some info rfork e screensize=(0 0 `{echo $vgasize | awk -Fx '{print $1, $2}'}) windows=`{for(win in /mnt/wsys/wsys/*) if(dd -if $win/wctl -bs 128 -count 1 -quiet 1 | grep -s visible) echo `{basename $win} } fn left{awk '{printf("%s %s %d %d %d %d", $1,$2,0,0,$5/2,$6)}'} fn right{awk '{printf("%s %s %d %d %d %d", $1,$2,$5/2,'$b',$5,'$e')}'} # auto tile windows if(~ $#windows 1) echo resize -r $screensize >/mnt/wsys/wsys/$windows/wctl if not{ echo current >/mnt/wsys/wsys/$windows(1)^/wctl echo resize -r $screensize | left >/mnt/wsys/wsys/$windows(1)^/wctl windows=`{echo $windows | sed 's/^[^ ]+ //'} # shift windows step=`{echo $screensize(4) / $#windows | bc} b=0; e=$step for(i in $windows){ echo current >/mnt/wsys/wsys/$i/wctl echo resize -r $screensize | right >/mnt/wsys/wsys/$i/wctl b=`{echo $b + $step | bc} e=`{echo $e + $step | bc} } }