aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2019-10-07 08:23:28 -0400
committerLoic Guegan <manzerbredes@mailbox.org>2019-10-07 08:23:28 -0400
commit1bb0ed2eb965e299e57c5df6eb4a97bde99dc1c6 (patch)
tree50a6602642fb1cbf4d7935727ea3adc47d109f9d
parent4a753e5e3d5e9c69377771a34d5de717eb6c6b35 (diff)
Allow i3 restart
-rw-r--r--TODO.org9
-rwxr-xr-xsrc/i3-theme.py23
-rwxr-xr-xsrc/parser.py1
3 files changed, 23 insertions, 10 deletions
diff --git a/TODO.org b/TODO.org
index aecc969..7af7a04 100644
--- a/TODO.org
+++ b/TODO.org
@@ -6,12 +6,15 @@
- [ ] Change src/theme.py name
- [ ] Improve function/variables names
-- YAML Theme Parser [0/1]:
+- YAML Theme Parser [0/2]:
- [ ] Improve yaml theme loader reliability
+ - [ ] Allow several metadata
-- Theme applying algorithm [0/2]:
+- Theme applying algorithm [0/3]:
- [ ] Improve efficiency
- [ ] Assume that theme to apply is well formated (checked in YAML Theme Parser)
+ - [ ] If there is no "colors" field in "bar" section, we still need to apply theme
-- General [0/1]:
+- General [1/2]:
- [ ] Improve user API
+ - [X] Allow -r option (restart i3)
diff --git a/src/i3-theme.py b/src/i3-theme.py
index 2fae302..fa31b1d 100755
--- a/src/i3-theme.py
+++ b/src/i3-theme.py
@@ -1,15 +1,26 @@
#!/usr/bin/python
-import parser, theme, os, argparse
+import parser, theme, os, argparse, subprocess
-args_parser = argparse.ArgumentParser(description='Process some integers.')
-args_parser.add_argument('theme_path', metavar='theme', type=str, nargs='?',
- help='YAML i3 theme path')
-args = args_parser.parse_args()
+##### Utils Functions #####
+def log(title, content): print("\033[92m{}\033[00m: {}" .format(title,content))
+###########################
+
+##### Parse Arguments #####
+args_parser = argparse.ArgumentParser(description='I3 Window Manager Colors Themer.')
+args_parser.add_argument('theme_path', type=str, nargs='?',
+ help='I3 YAML theme path.')
+args_parser.add_argument('-r', '--restart' ,action='store_true', help='Restart i3 after applying theme.')
+args = args_parser.parse_args()
+###########################
##### Apply Theme #####
loaded_theme=theme.load(args.theme_path)
+for meta_key,meta_value in loaded_theme["meta"].items():
+ log(meta_key.title(),meta_value)
parser.apply_theme(os.environ["HOME"]+"/.config/i3/config",loaded_theme)
-
+if args.restart:
+ subprocess.Popen("i3-msg restart".split())
+#######################
diff --git a/src/parser.py b/src/parser.py
index 9a4f4b0..fdee9fc 100755
--- a/src/parser.py
+++ b/src/parser.py
@@ -65,7 +65,6 @@ def apply_to_config(tmp_config,theme):
f.close()
def apply_theme(config_file,theme):
- print("Applying theme: "+theme["meta"]["description"])
tmp=extract_config(config_file)
apply_to_config(tmp,theme)
shutil.move(tmp,config_file)