diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2019-10-08 10:05:54 -0400 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2019-10-08 10:05:54 -0400 |
| commit | f3b050df7f0ef55a4b9f0bdf8a0b98679b858a3b (patch) | |
| tree | c5e64c5ed1cd1b7db5017efa1b667c0db19bba1b /src/config.py | |
| parent | 8d62ee31f1bd1a737761d8765f3f5ca081b5f935 (diff) | |
Now i3 theme can be generated from config files.
Diffstat (limited to 'src/config.py')
| -rwxr-xr-x | src/config.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/config.py b/src/config.py index c8fa8bd..80e264f 100755 --- a/src/config.py +++ b/src/config.py @@ -1,4 +1,4 @@ -import re,tempfile,shutil +import re,tempfile,shutil,theme config_keys=["client.focused", "client.focused_inactive", @@ -66,7 +66,31 @@ def extract(config_file): f.close() tmp.close() return(tmp.name) - + + +def extract_theme(config_file): + """ + Return a ThemeBuilder object of the config_file file. + """ + f=open(config_file,"r") + build=theme.ThemeBuilder() + in_colors=False + for line_orig in f: + line=no_comment(line_orig) + is_theme_line=False + for key in config_keys: + if contains(".*"+key+"\s",line): + is_theme_line=True + if contains(".*colors",line): + in_colors=True + if 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 + f.close() + return(build) + + def write_theme(tmp_config,theme): """ Write the theme in a temporary file |
