2023-03-06 19:08:25 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
. $HOME/.config/rootwm/rwm_var
|
|
|
|
|
|
|
|
FLAG=$1 # input
|
|
|
|
RID=$(lsw -r) # root window id
|
|
|
|
FW=$(pfw) # focused window
|
|
|
|
CMW=$(lsw | wc -l) # count maped windows
|
|
|
|
RW=$(wattr w $RID) # root width
|
|
|
|
RH=$(wattr h $RID) # root height
|
|
|
|
SW=$((RW - 2*BW)) # usable screen width
|
|
|
|
SH=$((RH - 2*BW)) # usable screen height
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "usage:
|
|
|
|
rwm_layout.sh [ -m, -t, -w ]
|
|
|
|
-m) monucule
|
|
|
|
-t) tiled
|
|
|
|
-w) widespread"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -n "$FW" ]; then
|
|
|
|
case $FLAG in
|
|
|
|
-m) # all windows at full screen
|
|
|
|
for wid in $(lsw); do
|
|
|
|
wtp 0 0 $SW $SH $wid
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
-t) # master and stack
|
|
|
|
wunfocus=$((CMW - 1)) # count unfocused windows
|
|
|
|
mp=$(atomx WM_MP $RID) # tiling master area percentage
|
|
|
|
master=$((SW * mp / 100)) # tilling master area
|
|
|
|
wmaster=$((master - 2*BW)) # master width
|
|
|
|
xstack=$master # stack X coordinate
|
|
|
|
ystack=0 # initial stack Y cooordinate
|
|
|
|
wstack=$((SW - master)) # stack width
|
|
|
|
hstack=$(((SH - (wunfocus - 1) * 2*BW) / wunfocus)) # stack heigth
|
|
|
|
|
|
|
|
wtp 0 0 $wmaster $SH $FW # focused window in master
|
|
|
|
|
|
|
|
for wid in $(lsw | grep -v $FW); do # unfocused windows in stack
|
|
|
|
wtp $xstack $ystack $wstack $hstack $wid
|
|
|
|
ystack=$((ystack + hstack + 2*BW)) # incremental stack Y corrdinate
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
-w) # widespread
|
2023-03-07 12:54:01 +01:00
|
|
|
wp=$(atomx WM_WP $RID)
|
|
|
|
ww=$((SW * wp / 100)) # windows width
|
|
|
|
wh=$((SH * wp / 100)) # windows height
|
2023-03-06 19:08:25 +01:00
|
|
|
x=$(((RW - ww) / (CMW*2))) # initial X coordinate
|
|
|
|
y=$(((RH - wh) / (CMW*2))) # initial Y coordinate
|
|
|
|
xmax=$(((RW - ww) / CMW)) # function X value
|
|
|
|
ymax=$(((RH - wh) / CMW)) # function Y value
|
|
|
|
|
|
|
|
for wid in $(lsw); do # windows in cascade
|
|
|
|
wtp $x $y $ww $wh $wid
|
|
|
|
x=$((x + xmax)) # incremental X value
|
|
|
|
y=$((y + ymax)) # incremental Y value
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|