mirror of
https://gitlab.com/manzerbredes/i3-colors.git
synced 2025-04-06 08:36:24 +02:00
Handle variables while extracting theme
This commit is contained in:
parent
58a2941879
commit
5dc172040f
3 changed files with 65 additions and 6 deletions
|
@ -83,7 +83,9 @@ def extract_theme(config_file):
|
|||
is_theme_line=True
|
||||
if contains(".*colors",line):
|
||||
in_colors=True
|
||||
if is_theme_line or in_colors:
|
||||
if contains("(\s)*set",line): # If var definition
|
||||
build.parse(line_orig)
|
||||
elif is_theme_line or in_colors:
|
||||
build.parse(line_orig) # Seems to by strange to have comment here
|
||||
if contains(".*}",line) and in_colors:
|
||||
in_colors=False
|
||||
|
|
23
src/theme.py
23
src/theme.py
|
@ -77,9 +77,18 @@ class ThemeBuilder:
|
|||
self.theme={"meta": {"description": "Generated From i3-colors"},
|
||||
"window_colors":dict(),
|
||||
"bar_colors":dict()}
|
||||
self.vars=list()
|
||||
self.vars_values=dict()
|
||||
|
||||
def dump(self):
|
||||
print(yaml.dump(self.theme))
|
||||
|
||||
def get(self,key):
|
||||
if key in self.vars:
|
||||
return(self.vars_values[key])
|
||||
else:
|
||||
return(key)
|
||||
|
||||
def parse(self,line):
|
||||
if re.match("client.*",line):
|
||||
tokens=line.split()
|
||||
|
@ -88,14 +97,14 @@ class ThemeBuilder:
|
|||
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
|
||||
self.theme["window_colors"][key][subkeys[0]]=self.get(token)
|
||||
subkeys.pop(0)
|
||||
elif re.match(".*background.*",line):
|
||||
self.theme["bar_colors"]["background"]=line.split()[1]
|
||||
self.theme["bar_colors"]["background"]=self.get(line.split()[1])
|
||||
elif re.match(".*statusline.*",line):
|
||||
self.theme["bar_colors"]["statusline"]=line.split()[1]
|
||||
self.theme["bar_colors"]["statusline"]=self.get(line.split()[1])
|
||||
elif re.match(".*separator.*",line):
|
||||
self.theme["bar_colors"]["separator"]=line.split()[1]
|
||||
self.theme["bar_colors"]["separator"]=self.get(line.split()[1])
|
||||
elif re.match(".*_workspace.*",line):
|
||||
tokens=line.split()
|
||||
key=tokens[0]
|
||||
|
@ -103,7 +112,11 @@ class ThemeBuilder:
|
|||
subkeys=["border","background","text"]
|
||||
self.theme["bar_colors"][key]=dict()
|
||||
for token in tokens:
|
||||
self.theme["bar_colors"][key][subkeys[0]]=token
|
||||
self.theme["bar_colors"][key][subkeys[0]]=self.get(token)
|
||||
subkeys.pop(0)
|
||||
elif re.match("(\s)*set",line):
|
||||
key,name,value=line.split()
|
||||
self.vars.append(name)
|
||||
self.vars_values[name]=value
|
||||
|
||||
|
||||
|
|
44
themes/google
Normal file
44
themes/google
Normal file
|
@ -0,0 +1,44 @@
|
|||
bar_colors:
|
||||
active_workspace:
|
||||
background: '#2d2d2d'
|
||||
border: '#414141'
|
||||
text: '#ffffff'
|
||||
background: '#2d2d2d'
|
||||
focused_workspace:
|
||||
background: '#2d76f6'
|
||||
border: '#4183F6'
|
||||
text: '#ffffff'
|
||||
inactive_workspace:
|
||||
background: '#2d2d2d'
|
||||
border: '#414141'
|
||||
text: '#bbbbbb'
|
||||
separator: '#bbbbbb'
|
||||
statusline: '#ffffff'
|
||||
urgent_workspace:
|
||||
background: '#ffc609'
|
||||
border: '#FFCB21'
|
||||
text: '#ffffff'
|
||||
meta:
|
||||
description: Generated From i3-colors
|
||||
window_colors:
|
||||
focused:
|
||||
background: '#2d76f6'
|
||||
border: '#4183F6'
|
||||
indicator: '#d8442e'
|
||||
text: '#ffffff'
|
||||
focused_inactive:
|
||||
background: '#bbbbbb'
|
||||
border: '#C1C1C1'
|
||||
indicator: '#009c58'
|
||||
text: '#ffffff'
|
||||
unfocused:
|
||||
background: '#2d2d2d'
|
||||
border: '#414141'
|
||||
indicator: '#bbbbbb'
|
||||
text: '#ffffff'
|
||||
urgent:
|
||||
background: '#ffc609'
|
||||
border: '#FFCB21'
|
||||
indicator: '#d8442e'
|
||||
text: '#ffffff'
|
||||
|
Loading…
Add table
Reference in a new issue