forked from Raymo111/i3lock-color
-
Notifications
You must be signed in to change notification settings - Fork 0
/
random_screensaver.sh
executable file
·36 lines (27 loc) · 982 Bytes
/
random_screensaver.sh
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
#!/bin/bash
# grab a random picture from unsplash and process for betterlockscreen
mkdir -p /var/tmp/backgrounds
XSAVER=`pgrep xscreensaver`
while true ; do
while pgrep i3lock
do
if [ `pgrep i3lock | wc -l` -lt 2 ]; then
killall i3lock
else
echo "screen locked"
DIMENSIONS=`xdpyinfo | grep dimensions | awk '{print $2}'`
wget -q -O /tmp/wallpaper.jpg https://source.unsplash.com/$DIMENSIONS/?travel,nature \
&& mv /tmp/wallpaper.jpg /var/tmp/backgrounds/
#sometimes it tries to process the file too quickly, so we wait
sleep 1
echo "wallpaper downloaded. refreshing i3lock cache"
betterlockscreen -u /var/tmp/backgrounds/wallpaper.jpg
sleep 1
echo "reloading i3lock"
I3LOCK=`pgrep i3lock | head -n 1` && echo $I3LOCK && kill -USR1 $I3LOCK
#wait 30 minutes till next refresh
sleep 1800
fi
done
sleep 5 #slow down how often it checks for i3lock
done