-
Notifications
You must be signed in to change notification settings - Fork 0
/
Theme_Selector.pyw
56 lines (39 loc) · 1.32 KB
/
Theme_Selector.pyw
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
56
## theme selector
import os
from time import sleep
import time
from apscheduler.schedulers.background import BlockingScheduler
from random import randrange
# changes to a random light theme with randrange by opening the file through the cmd
def joinlight():
light_num = randrange(3)
if light_num == 0:
os.popen(r"C:\Windows\Resources\Themes\aero.theme")
if light_num == 1:
os.popen(r"C:\Windows\Resources\Themes\themeC.theme")
else:
os.popen(r"C:\Windows\Resources\Themes\themeD.theme")
# changes to a random dark theme
def embracedark():
dark_num = randrange(3)
if dark_num == 0:
os.popen(r"C:\Windows\Resources\Themes\dark.theme")
if dark_num == 1:
os.popen(r"C:\Windows\Resources\Themes\themeA.theme")
else:
os.popen(r"C:\Windows\Resources\Themes\themeB.theme")
# Find local time
t = time.localtime()
# Extract the hour part
hr = time.strftime("%H", t)
#check time to apply theme on startup
if hr >= "6" or hr < "19":
joinlight()
else:
embracedark()
#imported scheduler to schedule each task for certain time of day
scheduler = BlockingScheduler()
scheduler.add_job(embracedark, 'cron', hour = 19)
scheduler.add_job(joinlight, 'cron', hour = 6)
#run the scheduled jobs
scheduler.start()