forked from zcoaolas/Emotion_Theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChangeTheme.py
91 lines (78 loc) · 2.77 KB
/
ChangeTheme.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
import os.path
import shutil
import time
from getImg import *
def call():
os.unlink("aero.theme")
os.system("aero_new.theme")
time.sleep(0.4)
os.rename("aero_new.theme", "aero.theme")
def change_theme(emotion):
print("Applying to system...")
current_working_dir = os.getcwd()
sys_theme_path = os.environ["appdata"] + "/../Local/Microsoft/Windows/Themes/"
if not os.path.exists(sys_theme_path + "aero.theme"):
shutil.copy("aero.theme", sys_theme_path + "aero.theme")
emotion_set = {"anger": 0, "contempt": 1, "disgust": 2, "fear": 3, "happiness": 4, "neutral": 5, "sadness": 6,
"surprise": 7}
emotion_colors = {0: "0x008080", 1: "0x007A11", 2: "0x003355", 3: "0x660066", 4: "0x800000",
5: "0x997300",
6: "0xe65c00", 7: "0x829900"}
# emotion = 'neutral'
wallpaper_path = ''
wallpaper_path = getImg(emotion_colors[emotion_set[emotion]])
wallpaper_path = current_working_dir + "/" + wallpaper_path
os.chdir(sys_theme_path)
theme_path = ""
desktop = "[Control Panel\Desktop]\n"
wallpaper = "Wallpaper="
style = "[VisualStyles]\n"
stylecolor = "ColorizationColor="
f = open(theme_path + "aero.theme", 'r+')
w = open(theme_path + "aero_new.theme", "w")
while True:
line = f.readline()
w.write(line)
if line.startswith(';'):
continue
if len(line) == 0:
break
if line == desktop:
flag = False
while flag == False:
inner_line = f.readline()
if inner_line.startswith(';'):
w.write(inner_line)
continue
if inner_line.startswith('\n'):
w.write(inner_line)
break
if inner_line[0:len(wallpaper)] == wallpaper:
w.write(wallpaper)
w.write(wallpaper_path + "\n")
flag = True
else:
w.write(inner_line)
elif line == style:
flag = False
while flag == False:
inner_line = f.readline()
if inner_line.startswith(';'):
w.write(inner_line)
continue
if inner_line.startswith('\n'):
w.write(inner_line)
break
if inner_line[0:len(stylecolor)] == stylecolor:
w.write(stylecolor)
w.write(emotion_colors[emotion_set[emotion]] + "\n")
flag = True
else:
w.write(inner_line)
else:
continue
f.close()
w.close()
call()
os.chdir(current_working_dir)