forked from chenasraf/BitDay-Linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·55 lines (45 loc) · 1.46 KB
/
update.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Original script by http://www.reddit.com/u/javajames64
# Updates by http://www.reddit.com/u/OhMrBigshot
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
sessionfile=`find "${HOME}/.dbus/session-bus/" -type f`
export `grep "DBUS_SESSION_BUS_ADDRESS" "${sessionfile}" | sed '/^#/d'`
files=(
11-Mid-Night.png
12-Late-Night.png
01-Early-Morning.png
02-Mid-Morning.png
03-Late-Morning.png
04-Early-Afternoon.png
05-Mid-Afternoon.png
06-Late-Afternoon.png
07-Early-Evening.png
08-Mid-Evening.png
09-Late-Evening.png
10-Early-Night.png
)
#Timings for the backgrounds in order. Your life may vary.
timing=(0 2 4 6 8 10 13 16 18 20 21)
hour=`date +%H`
hour=$(echo $hour | sed 's/^0*//')
# Different desktop environment implementations
case $XDG_CURRENT_DESKTOP in
Mint|Mate) setcmd="gsettings set org.mate.background picture-uri";;
Cinnamon) setcmd="gsettings set org.cinnamon.background picture-uri";;
*) setcmd="gsettings set org.gnome.desktop.background picture-uri";; # GNOME/Unity, default
esac
if [[ -z $XDG_CURRENT_DESKTOP ]]; then # Fallback for i3
case $DESKTOP_SESSION in
i3) setcmd="feh --bg-fill"
esac
fi
for i in $timing; do # Loop backwards through the wallpapers
if (( $hour >= $i )); then
$setcmd file://$DIR/${files[i]}
echo "Wallpaper set to ${files[i]}"
exit
fi
done
# Fallback at last wallpaper if time is not relevant
$setcmd file://$DIR/${files[7]}
echo "Wallpaper set to ${files[7]}"