aboutsummaryrefslogtreecommitdiff
path: root/src/theme.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/theme.py')
-rw-r--r--src/theme.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/theme.py b/src/theme.py
index d83b6b5..943832c 100644
--- a/src/theme.py
+++ b/src/theme.py
@@ -1,4 +1,4 @@
-import yaml,re
+import yaml,re, sys
def configure(theme):
if "colors" in theme:
@@ -22,8 +22,27 @@ def configure(theme):
theme["bar_colors"]=bar_colors
return(theme)
+def validate(theme):
+ abort=lambda msg: sys.exit("Error while loading theme: "+msg)
+ inv_key=lambda key: abort("invalid key \""+key+"\"")
+ for key,value in theme.items():
+ if not(key in ["meta","colors","window_colors","bar_colors"]):
+ inv_key(key)
+ if key=="bar_colors":
+ for key,value in value.items():
+ if not(key in ["separator","background","statusline",
+ "focused_workspace","active_workspace","inactive_workspace","urgent_workspace"]):
+ inv_key(key)
+ if key=="window_colors":
+ for key,value in value.items():
+ if not(key in ["focused","focused_inactive","unfocused","urgent","child_border"]):
+ inv_key(key)
+
+
def load(theme_file):
f=open(theme_file,mode="r")
theme=yaml.load(f,Loader=yaml.FullLoader)
f.close()
- return(configure(theme))
+ theme=configure(theme)
+ validate(theme)
+ return(theme)