-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.py
45 lines (37 loc) · 961 Bytes
/
background.py
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
from os import system as s
from datetime import datetime
sunrise = "06"
noon = "12"
sunset = "17"
night = "20"
time_of_day = datetime.now()
real_time = time_of_day.strftime("%H")
def switch_background(path):
s(
'osascript -e \'tell application "System Events" to set picture of every desktop to POSIX file "{}"\''.format(
path
)
)
def switch_on_time():
if real_time > sunrise and real_time < noon:
switch_background(
"dawn.jpg"
)
elif real_time <= sunrise:
switch_background(
"night.jpg"
)
elif real_time >= noon and real_time < sunset:
switch_background(
"noon.jpg"
)
elif real_time >= sunset and real_time < night:
switch_background(
"sunset.jpg"
)
elif real_time >= night:
switch_background(
"night.jpg"
)
if __name__ == "__main__":
switch_on_time()