This repository has been archived by the owner on Sep 27, 2022. It is now read-only.
forked from linuxmint/mint-themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-variations.py
executable file
·122 lines (105 loc) · 4.41 KB
/
update-variations.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/python3
import os
import sys
from constants import Y_HEX_ACCENT1, Y_HEX_ACCENT2, Y_HEX_ACCENT3, Y_HEX_ACCENT4
from constants import y_hex_colors1, y_hex_colors2, y_hex_colors3, y_hex_colors4
def change_value (key, value, file):
if value is not None:
command = "sed -i '/%(key)s=/c\%(key)s=%(value)s' %(file)s" % {'key':key, 'value':value, 'file':file}
else:
command = "sed -i '/%(key)s=/d' %(file)s" % {'key':key, 'file':file}
os.system(command)
def usage ():
print ("Usage: update-variations.py color")
print ("color can be 'Aqua', 'Blue', 'Brown', 'Grey', 'Orange', 'Pink', 'Purple', 'Red', 'Sand', 'Teal', 'Yellow' or 'All'.")
sys.exit(1)
def update_color (color):
variation = curdir+"/src/Mint-Y/variations/%s" % color
rendering_script = curdir+"/src/Mint-Y/render-assets.sh"
print("updating %s" % color)
os.system("rm -rf %s" % variation)
os.system("mkdir -p %s/gtk-2.0" % variation)
os.system("mkdir -p %s/gtk-3.0" % variation)
os.system("mkdir -p %s/gtk-4.0" % variation)
os.system("mkdir -p %s/xfwm4" % variation)
os.system("mkdir -p %s/xfwm4-dark" % variation)
# Copy assets files
assets = []
assets.append("gtk-2.0/assets.svg")
assets.append("gtk-2.0/assets-dark.svg")
assets.append("gtk-3.0/assets.svg")
assets.append("gtk-4.0/assets.svg")
assets.append("xfwm4/assets.svg")
assets.append("xfwm4-dark/assets.svg")
files = []
files.append("gtk-2.0/assets")
files.append("gtk-2.0/assets-dark")
files.append("gtk-2.0/assets.txt")
files.append("gtk-3.0/assets")
files.append("gtk-3.0/assets.txt")
files.append("gtk-4.0/assets")
files.append("gtk-4.0/assets.txt")
files.append("xfwm4/assets.txt")
files.append("xfwm4-dark/assets.txt")
for file in files:
os.system("cp -R src/Mint-Y/%s %s/%s" % (file, variation, file))
for asset in assets:
os.system("cp -R src/Mint-Y/%s %s/%s" % (asset, variation, asset))
# Update assets svg
for asset in assets:
asset_path = "%s/%s" % (variation, asset)
for accent in Y_HEX_ACCENT1:
os.system("sed -i s'/%(accent)s/%(color_accent)s/gI' %(file)s" % {'accent': accent, 'color_accent': y_hex_colors1[color], 'file': asset_path})
for accent in Y_HEX_ACCENT2:
os.system("sed -i s'/%(accent)s/%(color_accent)s/gI' %(file)s" % {'accent': accent, 'color_accent': y_hex_colors2[color], 'file': asset_path})
for accent in Y_HEX_ACCENT3:
os.system("sed -i s'/%(accent)s/%(color_accent)s/gI' %(file)s" % {'accent': accent, 'color_accent': y_hex_colors3[color], 'file': asset_path})
for accent in Y_HEX_ACCENT4:
os.system("sed -i s'/%(accent)s/%(color_accent)s/gI' %(file)s" % {'accent': accent, 'color_accent': y_hex_colors4[color], 'file': asset_path})
# Render assets
# TODO: need better idea to do '-dark'
# and '@2' arguments
os.chdir(variation)
os.chdir(variation+"/gtk-2.0")
print("**Rendering gtk-2.0 assets...")
os.system("rm -rf assets/*")
os.system(rendering_script)
print("**Rendering gtk-2.0 dark assets...")
os.system("rm -rf assets-dark/*")
os.system(rendering_script+" -dark")
# os.system("rm -rf assets/*@2.png")
print("**Rendering gtk-3.0 assets...")
os.chdir(variation+"/gtk-3.0/")
os.system("rm -rf assets/*")
os.system(rendering_script+" s2")
print("**Rendering gtk-4.0 assets...")
os.chdir(variation+"/gtk-4.0/")
os.system("rm -rf assets/*")
os.system(rendering_script+" s2")
print("**Rendering xfwm4 assets...")
os.chdir(variation+"/xfwm4/")
os.system("rm -rf *.png")
os.system(rendering_script)
# os.system("rm -rf assets/*@2.png")
os.system("mv assets/*.png ./ && rm -rf assets/")
print("**Rendering xfwm4 dark assets...")
os.chdir(variation+"/xfwm4-dark/")
os.system("rm -rf *.png")
os.system(rendering_script)
# os.system("rm -rf assets/*@2.png")
os.system("mv assets/*.png ./ && rm -rf assets/")
print("")
os.chdir(curdir)
if len(sys.argv) < 2:
usage()
else:
color_variation = sys.argv[1]
if not color_variation in ["Aqua", "Blue", "Brown", "Grey", "Orange", "Pink", "Purple", "Red", "Sand", "Teal", "Yellow", "All"]:
usage()
# Mint-Y variations
curdir = os.getcwd()
if color_variation == "All":
for color in y_hex_colors1.keys():
update_color(color)
else:
update_color(color_variation)