-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageChanger.sh
50 lines (44 loc) · 956 Bytes
/
imageChanger.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
#! /bin/bash
function random_wall ()
{
# BACKUP IMAGES IN CASE OF GOING DARK
path_name="/Users/Furkan/Pictures/Selection/"
my_number=$[RANDOM%$1+1]
my_wall="$path_name$2-$my_number.jpg"
sec1='tell application "System Events" to set picture of every desktop to ("'
# IF INTERNET WORKS
fooShell=$(python PATH_TO_FILE/pull_and_change.py)
echo $fooShell
if [ "$fooShell" == "FAIL" ]
then
sec1+=$my_wall
sec2='" as POSIX file as alias)'
sec1+=$sec2
else
sec1+=$fooShell
sec2='" as POSIX file as alias)'
sec1+=$sec2
fi
osascript -e "$sec1"
}
hour=$(date +"%H")
if [ $hour -ge "5" ] && [ $hour -le "9" ]
then
random_wall 8 early-morning
fi
if [ $hour -ge "9" ] && [ $hour -lt "13" ]
then
random_wall 17 morning
fi
if [ $hour -ge "13" ] && [ $hour -lt "17" ]
then
random_wall 19 midday
fi
if [ $hour -ge "17" ] && [ $hour -lt "20" ]
then
random_wall 15 afternoon
fi
if [ $hour -ge "20" ] || [ $hour -lt "5" ]
then
random_wall 19 night
fi