blob: a035c0370fa2691c6068b3815e4fa9ca038a55a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/bin/sh
WALLPAPER_PATH="$HOME/Images/Wallpaper"
INTERVAL=600
while getopts 'p::t::' OPTION; do
case "$OPTION" in
p)
WALLPAPER_PATH="$OPTARG"
;;
t)
INTERVAL="$OPTARG"
;;
?)
echo "Usage: {$0} [--path=] [--time=]"
exit 1
;;
esac
done
RUNNING_PID=-1
while true; do
# run swaybg
RANDOM_NUMBER=$(shuf -i 1-10 -n 1)
if [ $RANDOM_NUMBER -le 2 ]; then
swaybg -i "$(find "$WALLPAPER_PATH" -type f | shuf -n1)" -m fill &
else
swaybg -i "$(find "$WALLPAPER_PATH" -type f -not -path "*/hyper-pokemon/*" | shuf -n1)" -m fill &
fi
# get pid of new spawned instance
NEW_PID=$!
# wait until new instance of swaybg has booted up properly
sleep 5
# kill the previous process
# the new swaybg process takes its place automatically
kill $RUNNING_PID
# set pid for next iteration
RUNNING_PID=$NEW_PID
# wait $INTERVAL seconds
sleep $INTERVAL
done
|