From 71688839f0c3fb8107bbea27eb6cb1b4d8277e4a Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 6 Oct 2019 23:05:44 -0400 Subject: Add theme manager --- src/theme.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/theme.py (limited to 'src/theme.py') diff --git a/src/theme.py b/src/theme.py new file mode 100644 index 0000000..187b8d2 --- /dev/null +++ b/src/theme.py @@ -0,0 +1,30 @@ +import yaml,re + + +def configure(theme): + if "colors" in theme: + colors=theme["colors"] + window_colors=theme["window_colors"] + for key1,value1 in window_colors.items(): + for key2,value2 in value1.items(): + if re.match("#.*",value2) == None: + window_colors[key1][key2]=colors[value2] + theme["window_colors"]=window_colors + + bar_colors=theme["bar_colors"] + for key1,value1 in bar_colors.items(): + if isinstance(value1,dict): + for key2,value2 in value1.items(): + if re.match("#.*",value2) == None: + bar_colors[key1][key2]=colors[value2] + else: + if re.match("#.*",value1) == None: + bar_colors[key1]=colors[value1] + theme["bar_colors"]=bar_colors + return(theme) + +def load(theme_file): + f=open(theme_file,mode="r") + theme=yaml.load(f,Loader=yaml.FullLoader) + f.close() + return(configure(theme)) -- cgit v1.2.3