-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.py
50 lines (41 loc) · 2.31 KB
/
convert.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
#!/usr/bin/env python3
import os
import json
from string import Template
NOCTIS_THEMES_DIR = "noctis/themes"
OUTPUT_DIR = "themes"
def main():
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
template = Template(open("template.toml").read())
for variant in os.listdir(NOCTIS_THEMES_DIR):
variant_name = variant.split(".")[0]
with open(os.path.join(NOCTIS_THEMES_DIR, variant)) as f:
variant_definition = json.load(f)
theme = {
"background": variant_definition["colors"]["editor.background"],
"foreground": variant_definition["colors"]["editor.foreground"],
"cursor_background": variant_definition["colors"]["editor.background"],
"cursor_foreground": variant_definition["colors"]["editorCursor.foreground"],
"black": variant_definition["colors"]["terminal.ansiBlack"],
"red": variant_definition["colors"]["terminal.ansiRed"],
"green": variant_definition["colors"]["terminal.ansiGreen"],
"yellow": variant_definition["colors"]["terminal.ansiYellow"],
"blue": variant_definition["colors"]["terminal.ansiBlue"],
"magenta": variant_definition["colors"]["terminal.ansiMagenta"],
"cyan": variant_definition["colors"]["terminal.ansiCyan"],
"white": variant_definition["colors"]["terminal.ansiWhite"],
"bright_black": variant_definition["colors"]["terminal.ansiBrightBlack"],
"bright_red": variant_definition["colors"]["terminal.ansiBrightRed"],
"bright_green": variant_definition["colors"]["terminal.ansiBrightGreen"],
"bright_yellow": variant_definition["colors"]["terminal.ansiBrightYellow"],
"bright_blue": variant_definition["colors"]["terminal.ansiBrightBlue"],
"bright_magenta": variant_definition["colors"]["terminal.ansiBrightMagenta"],
"bright_cyan": variant_definition["colors"]["terminal.ansiBrightCyan"],
"bright_white": variant_definition["colors"]["terminal.ansiBrightWhite"],
}
output_file = "noctis.toml" if variant_name == "noctis" else f"noctis-{variant_name}.toml"
with open(os.path.join(OUTPUT_DIR, output_file), "w") as f:
f.write(template.substitute(theme))
if __name__ == "__main__":
main()