2024-02-07 03:18:02 +01:00
|
|
|
|
2023-03-06 19:08:25 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-03-07 14:01:29 +01:00
|
|
|
## some layouts to order the windows ##
|
|
|
|
|
2023-08-08 04:42:24 +02:00
|
|
|
. /tmp/wms_var
|
2023-03-06 19:08:25 +01:00
|
|
|
|
2024-01-21 04:05:04 +01:00
|
|
|
FLAG=$1
|
|
|
|
# root window id.
|
|
|
|
RID=$(lsw -r)
|
|
|
|
# focused window.
|
|
|
|
FW=$(pfw)
|
|
|
|
# count maped windows.
|
|
|
|
CMW=$(lsw | wc -l)
|
|
|
|
# root width.
|
|
|
|
RW=$(wattr w $RID)
|
|
|
|
# root height.
|
|
|
|
RH=$(wattr h $RID)
|
|
|
|
# usable screen width.
|
|
|
|
SW=$((RW - 2 * BW))
|
|
|
|
# usable screen height.
|
|
|
|
SH=$((RH - 2 * BW))
|
2023-03-06 19:08:25 +01:00
|
|
|
|
|
|
|
usage() {
|
2023-07-24 08:08:48 +02:00
|
|
|
cat<<EOF
|
|
|
|
usage:
|
2023-03-20 02:46:41 +01:00
|
|
|
wms_usher.sh [ -m, -t, -w ]
|
2023-03-06 19:08:25 +01:00
|
|
|
-m) monucule
|
|
|
|
-t) tiled
|
2023-07-24 08:08:48 +02:00
|
|
|
-w) widespread
|
|
|
|
EOF
|
2023-03-06 19:08:25 +01:00
|
|
|
}
|
|
|
|
|
2023-03-09 05:41:12 +01:00
|
|
|
# all windows at full screen
|
|
|
|
monocule() {
|
|
|
|
for wid in $(lsw); do
|
|
|
|
wtp 0 0 $SW $SH $wid
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# tiling. Master and stack
|
|
|
|
tiling() {
|
2024-01-21 04:05:04 +01:00
|
|
|
# screen widht width gaps added.
|
|
|
|
sw=$((RW - 2 * GAP - 2 * BW))
|
|
|
|
# master screen height.
|
|
|
|
msh=$((RH - 2 * GAP - 2 * BW))
|
|
|
|
# stack screen height (( - BW))?
|
|
|
|
ssh=$((RH - GAP))
|
|
|
|
# stack windows count.
|
|
|
|
swcount=$((CMW - 1))
|
|
|
|
# master area width.
|
|
|
|
mwidth=$((sw * MP / 100 - 2 * BW))
|
|
|
|
# master area height.
|
|
|
|
mheight=$msh
|
|
|
|
# master X coordinate.
|
|
|
|
mx=$GAP
|
|
|
|
# master Y coordinate.
|
|
|
|
my=$GAP
|
|
|
|
# stack width.
|
|
|
|
swidth=$((sw - mwidth - GAP - 2 * BW))
|
|
|
|
# stack height.
|
|
|
|
sheight=$((ssh / swcount - GAP - 2 * BW))
|
|
|
|
# stack x coordinate.
|
|
|
|
sx=$((mwidth + 2 * GAP + 2 * BW))
|
|
|
|
# stack y coordinate.
|
|
|
|
sy=$GAP
|
2023-03-09 05:41:12 +01:00
|
|
|
|
2023-04-14 05:18:41 +02:00
|
|
|
# put focused window as master
|
2023-08-07 04:23:00 +02:00
|
|
|
wtp $mx $my $mwidth $mheight $FW
|
2023-04-14 05:18:41 +02:00
|
|
|
|
|
|
|
# put the rest of the windows in stack
|
|
|
|
for wid in $(lsw | grep -v $FW); do
|
2023-08-07 04:23:00 +02:00
|
|
|
wtp $sx $sy $swidth $sheight $wid
|
2024-01-21 04:05:04 +01:00
|
|
|
# incremental stack Y coordinate.
|
|
|
|
sy=$((sy + sheight + GAP + 2 * BW))
|
2023-03-09 05:41:12 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# widespread
|
|
|
|
widespread() {
|
2024-01-21 04:05:04 +01:00
|
|
|
# windows width.
|
|
|
|
ww=$((SW * WP / 100))
|
|
|
|
# windows height.
|
|
|
|
wh=$((SH * WP / 100))
|
|
|
|
# initial X coordinate.
|
|
|
|
x=$(((RW - ww) / (CMW * 2)))
|
|
|
|
# initial Y coordinate.
|
|
|
|
y=$(((RH - wh) / (CMW * 2)))
|
|
|
|
# function X value.
|
|
|
|
xmax=$(((RW - ww) / CMW))
|
|
|
|
# function Y value.
|
|
|
|
ymax=$(((RH - wh) / CMW))
|
2023-03-09 05:41:12 +01:00
|
|
|
|
2023-04-14 05:18:41 +02:00
|
|
|
# put windows in cascade
|
|
|
|
for wid in $(lsw); do
|
2023-03-09 05:41:12 +01:00
|
|
|
wtp $x $y $ww $wh $wid
|
2024-01-21 04:05:04 +01:00
|
|
|
# incremental X value.
|
|
|
|
x=$((x + xmax))
|
|
|
|
# incremental Y value.
|
|
|
|
y=$((y + ymax))
|
2023-03-09 05:41:12 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2024-01-21 04:05:04 +01:00
|
|
|
# if there is a focused window.
|
|
|
|
if [ -n "$FW" ]; then
|
2023-03-06 19:08:25 +01:00
|
|
|
case $FLAG in
|
2023-03-09 05:41:12 +01:00
|
|
|
-m)
|
|
|
|
monocule
|
2023-03-06 19:08:25 +01:00
|
|
|
;;
|
2023-03-09 05:41:12 +01:00
|
|
|
-t)
|
|
|
|
tiling
|
2023-03-06 19:08:25 +01:00
|
|
|
;;
|
2023-03-09 05:41:12 +01:00
|
|
|
-w)
|
|
|
|
widespread
|
2023-03-06 19:08:25 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|