91 lines
2.7 KiB
Bash
Executable file
91 lines
2.7 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
## some layouts to order the windows ##
|
|
|
|
. $HOME/.config/wms/wms_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:
|
|
wms_usher.sh [ -m, -t, -w ]
|
|
-m) monucule
|
|
-t) tiled
|
|
-w) widespread"
|
|
}
|
|
|
|
# all windows at full screen
|
|
monocule() {
|
|
for wid in $(lsw); do
|
|
wtp 0 0 $SW $SH $wid
|
|
done
|
|
}
|
|
|
|
# tiling. Master and stack
|
|
tiling() {
|
|
gap=$(atomx WM_GAP $RID) # gaps
|
|
sw=$((RW - 2 * gap - 2 * BW)) # screen widht width gaps added
|
|
msh=$((RH - 2 * gap - 2 * BW)) # master screen height
|
|
ssh=$((RH - gap)) # stack screen height ((- BW))?
|
|
sw_count=$((CMW - 1)) # stack windows count
|
|
m_perc=$(atomx WM_MP $RID) # master area percent
|
|
m_width=$((sw * m_perc / 100 - 2 * BW)) # master area width
|
|
m_height=$msh # master area height
|
|
mx=$gap # master x coordinate
|
|
my=$gap # master y coordinate
|
|
s_width=$((sw - m_width - gap - 2 * BW)) # stack width
|
|
s_height=$((ssh / sw_count - gap - 2 * BW)) # stack height
|
|
sx=$((m_width + 2 * gap + 2 * BW)) # stack x coordinate
|
|
sy=$gap # stack y coordinate
|
|
|
|
# put focused window as master
|
|
wtp $mx $my $m_width $m_height $FW
|
|
|
|
# put the rest of the windows in stack
|
|
for wid in $(lsw | grep -v $FW); do
|
|
wtp $sx $sy $s_width $s_height $wid
|
|
sy=$((sy + s_height + gap + 2 * BW)) # incremental stack y coordinate
|
|
done
|
|
}
|
|
|
|
# widespread
|
|
widespread() {
|
|
wp=$(atomx WM_WP $RID) # window percentage from atom
|
|
ww=$((SW * wp / 100)) # windows width
|
|
wh=$((SH * wp / 100)) # windows height
|
|
x=$(((RW - ww) / (CMW * 2))) # initial X coordinate
|
|
y=$(((RH - wh) / (CMW * 2))) # initial Y coordinate
|
|
x_max=$(((RW - ww) / CMW)) # function X value
|
|
y_max=$(((RH - wh) / CMW)) # function Y value
|
|
|
|
# put windows in cascade
|
|
for wid in $(lsw); do
|
|
wtp $x $y $ww $wh $wid
|
|
x=$((x + x_max)) # incremental X value
|
|
y=$((y + y_max)) # incremental Y value
|
|
done
|
|
}
|
|
|
|
if [ -n "$FW" ]; then # if there is a focused window
|
|
case $FLAG in
|
|
-m)
|
|
monocule
|
|
;;
|
|
-t)
|
|
tiling
|
|
;;
|
|
-w)
|
|
widespread
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|
|
fi
|