themes: Add support for terminal.sexy json

This commit is contained in:
Dylan Araps 2018-03-15 17:19:01 +11:00
parent a95d901dea
commit 90a73edda5
3 changed files with 48 additions and 1 deletions

View File

@ -127,6 +127,24 @@ def get(img, cache_dir=CACHE_DIR,
return colors return colors
def terminal_sexy_to_wal(data):
"""Convert terminal.sexy json schema to wal."""
data["colors"] = {}
data["special"] = {}
for i in range(0, 16):
data["colors"]["color%s" % i] = data["color"][i if i < 9 else i - 8]
data["colors"]["color0"] = data["background"]
data["colors"]["color7"] = data["foreground"]
data["colors"]["color15"] = data["foreground"]
data["special"]["foreground"] = data["foreground"]
data["special"]["background"] = data["background"]
data["special"]["cursor"] = data["colors"]["color1"]
return data
def file(input_file): def file(input_file):
"""Import colorscheme from json file.""" """Import colorscheme from json file."""
theme_file = os.path.join(MODULE_DIR, "colorschemes", theme_file = os.path.join(MODULE_DIR, "colorschemes",
@ -144,6 +162,10 @@ def file(input_file):
if "alpha" not in data: if "alpha" not in data:
data["alpha"] = "100" data["alpha"] = "100"
# Terminal.sexy format.
if isinstance(data["color"], list):
data = terminal_sexy_to_wal(data)
return data return data
else: else:

View File

@ -2,7 +2,7 @@
"special": { "special": {
"background": "#282828", "background": "#282828",
"foreground": "#a89984", "foreground": "#a89984",
"cursor": "#dc322f" "cursor": "#cc241d"
}, },
"colors": { "colors": {
"color0": "#282828", "color0": "#282828",

View File

@ -0,0 +1,25 @@
{
"special": {
"background": "#3f3f3f",
"foreground": "#dcdccc",
"cursor": "#cc9393"
},
"colors": {
"color0": "#3f3f3f",
"color1": "#cc9393",
"color2": "#7f9f7f",
"color3": "#d0bf8f",
"color4": "#6ca0a3",
"color5": "#dc8cc3",
"color6": "#93e0e3",
"color7": "#dcdccc",
"color8": "#828282",
"color9": "#cc9393",
"color10": "#7f9f7f",
"color11": "#d0bf8f",
"color12": "#6ca0a3",
"color13": "#dc8cc3",
"color14": "#93e0e3",
"color15": "#dcdccc"
}
}