aboutsummaryrefslogtreecommitdiff
path: root/src/theme.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/theme.py')
-rw-r--r--src/theme.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/theme.py b/src/theme.py
index 50a7ee0..fd1461a 100644
--- a/src/theme.py
+++ b/src/theme.py
@@ -56,7 +56,7 @@ def validate(theme):
for key,value in value.items():
if not(key in ["focused","focused_inactive","unfocused","urgent","child_border"]):
inv_key(key)
-
+
def load(theme_file):
"""
Load a theme as a dict():
@@ -71,3 +71,39 @@ def load(theme_file):
theme=configure(theme)
validate(theme)
return(theme)
+
+class ThemeBuilder:
+ def __init__(self):
+ self.theme={"meta": {"description": "Generated From i3-colors"},
+ "window_colors":dict(),
+ "bar_colors":dict()}
+ def dump(self):
+ print(yaml.dump(self.theme))
+
+ def parse(self,line):
+ if re.match("client.*",line):
+ tokens=line.split()
+ key=tokens[0].replace("client.","")
+ tokens.pop(0)
+ subkeys=["border","background","text","indicator","child_border"]
+ self.theme["window_colors"][key]=dict()
+ for token in tokens:
+ self.theme["window_colors"][key][subkeys[0]]=token
+ subkeys.pop(0)
+ elif re.match(".*background.*",line):
+ self.theme["bar_colors"]["background"]=line.split()[1]
+ elif re.match(".*statusline.*",line):
+ self.theme["bar_colors"]["statusline"]=line.split()[1]
+ elif re.match(".*separator.*",line):
+ self.theme["bar_colors"]["separator"]=line.split()[1]
+ elif re.match(".*_workspace.*",line):
+ tokens=line.split()
+ key=tokens[0]
+ tokens.pop(0)
+ subkeys=["border","background","text"]
+ self.theme["bar_colors"][key]=dict()
+ for token in tokens:
+ self.theme["bar_colors"][key][subkeys[0]]=token
+ subkeys.pop(0)
+
+