diff --git a/src/config.py b/src/config.py index 9e2f070..a94c288 100755 --- a/src/config.py +++ b/src/config.py @@ -14,10 +14,24 @@ config_keys=["client.focused", "inactive_workspace", "urgent_workspace"] +##### Parsing Utils ##### def contains(r,line): + """ + Return true if line contains regex r. + """ return(re.match(r,line)!=None) - +def before_token(token, line): + """ + Return what is before token in line. + """ + found=re.search(".*"+token,line) + if found: + return(found.group(0)[:-len(token)]) + return("") def no_comment(line): + """ + Remove comment from a line. + """ newline="" for ch in line: if ch=='#': @@ -25,7 +39,9 @@ def no_comment(line): else: newline+=ch return(newline) - +######################### + + def extract(config_file): """ Return a temporary file path containing the current user configuration @@ -99,7 +115,7 @@ def write_theme(tmp_config,theme): client_theme=theme["window_colors"] f=open(tmp_config,mode="a") for key,value in client_theme.items(): - f.write("client."+key+" "+value["border"]+" "+value["background"]+" "+value["text"]+" "+value["indicator"]+" "+safe_get(value,"child_border")+"\n") + f.write("client."+key+" "+value["border"]+" "+value["background"]+" "+value["text"]+" "+value["indicator"]+" "+value["child_border"]+"\n") f.close() diff --git a/src/theme.py b/src/theme.py index 943832c..ad59ca4 100644 --- a/src/theme.py +++ b/src/theme.py @@ -4,12 +4,16 @@ def configure(theme): if "colors" in theme: colors=theme["colors"] window_colors=theme["window_colors"] + + ##### Apply colors to window ##### 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 - + ################################## + + ##### Apply color to bar ##### bar_colors=theme["bar_colors"] for key1,value1 in bar_colors.items(): if isinstance(value1,dict): @@ -20,6 +24,15 @@ def configure(theme): if re.match("#.*",value1) == None: bar_colors[key1]=colors[value1] theme["bar_colors"]=bar_colors + ############################## + + ##### I3-style theme do not include child_border by default ##### + window_colors=theme["window_colors"] + for key,value in window_colors.items(): + if not("child_border" in value): + newvalue=value + theme["window_colors"][key]["child_border"]=newvalue["border"] # Set it to border by default + ################################################################# return(theme) def validate(theme):