2023-03-12 04:54:44 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
## use the windows on the desktop as screensavers by moving them randomly
|
|
|
|
|
2023-08-08 04:42:24 +02:00
|
|
|
. /tmp/wms_var
|
2023-03-12 04:54:44 +01:00
|
|
|
|
|
|
|
INPUT=$1 # input
|
|
|
|
FW=$(pfw) # focused window
|
|
|
|
SW=$(wattr w $(lsw -r)) # screen width
|
|
|
|
SH=$(wattr h $(lsw -r)) # screen height
|
2023-03-28 14:30:53 +02:00
|
|
|
WW=$((SW * 80 / 100)) # windows width = 80% of the screen
|
|
|
|
WH=$((SH * 80 / 100)) # windows height = 80% of the screen
|
2023-03-12 04:54:44 +01:00
|
|
|
MAXX=$((SW - WW)) # max X coordinate
|
|
|
|
MAXY=$((SH - WH)) # max Y coordinate
|
|
|
|
FREQ=20 # refresh frequency
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "usage:
|
2023-03-20 02:46:41 +01:00
|
|
|
wms_screensaver.sh [ -a, -f ]
|
2023-03-12 04:54:44 +01:00
|
|
|
-a) all windows
|
|
|
|
-f) focused window"
|
|
|
|
}
|
|
|
|
|
|
|
|
# random movement for all windowsaver
|
|
|
|
all_win() {
|
|
|
|
while true; do
|
|
|
|
for wid in $(lsw); do
|
2023-03-28 06:24:25 +02:00
|
|
|
x=$(shuf -i 0-$MAXX -n 1) # random x coordinate
|
|
|
|
y=$(shuf -i 0-$MAXY -n 1) # random y coordinate
|
2023-03-12 04:54:44 +01:00
|
|
|
wtp $x $y $WW $WH $wid
|
|
|
|
done
|
|
|
|
sleep $FREQ
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# random movement for the focused window
|
|
|
|
focused_win() {
|
|
|
|
while true; do
|
|
|
|
x=$(shuf -i 0-$MAXX -n 1)
|
|
|
|
y=$(shuf -i 0-$MAXY -n 1)
|
|
|
|
wtp $x $y $WW $WH $FW
|
|
|
|
sleep $FREQ
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
case $INPUT in
|
|
|
|
-a)
|
|
|
|
all_win
|
|
|
|
;;
|
|
|
|
-f)
|
|
|
|
focused_win
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|