aboutsummaryrefslogtreecommitdiff
path: root/src/i3-colors.py
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2019-10-08 10:05:54 -0400
committerLoic Guegan <manzerbredes@mailbox.org>2019-10-08 10:05:54 -0400
commitf3b050df7f0ef55a4b9f0bdf8a0b98679b858a3b (patch)
treec5e64c5ed1cd1b7db5017efa1b667c0db19bba1b /src/i3-colors.py
parent8d62ee31f1bd1a737761d8765f3f5ca081b5f935 (diff)
Now i3 theme can be generated from config files.
Diffstat (limited to 'src/i3-colors.py')
-rwxr-xr-xsrc/i3-colors.py41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/i3-colors.py b/src/i3-colors.py
index 925ff3a..0afafcd 100755
--- a/src/i3-colors.py
+++ b/src/i3-colors.py
@@ -9,21 +9,36 @@ def log(msg,title=""):
print(msg)
###########################
+##### Apply Theme #####
+def apply(args):
+ loaded_theme=theme.load(args.theme_path)
+ config.apply(os.environ["HOME"]+"/.config/i3/config",loaded_theme)
+ for meta_key,meta_value in loaded_theme["meta"].items():
+ log(meta_value,title=meta_key.title())
+ if args.restart:
+ subprocess.Popen("i3-msg restart".split(),stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+#######################
+
+##### Extract Theme #####
+def extract(args):
+ theme=config.extract_theme(args.config_path)
+ theme.dump()
+#######################
##### Parse Arguments #####
-args_parser = argparse.ArgumentParser(description='I3 Window Manager Colors Themer.')
-args_parser.add_argument('theme_path', type=str, nargs='?',
+argsMainParser = argparse.ArgumentParser(description='I3 Window Manager Colors Themer.')
+argsSubParsers = argsMainParser.add_subparsers()
+argsApplyParser = argsSubParsers.add_parser("apply")
+argsApplyParser.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()
-###########################
+argsApplyParser.add_argument('-r', '--restart' ,action='store_true', help='Restart i3 after applying theme.')
+argsApplyParser.set_defaults(func=apply)
-##### Apply Theme #####
-loaded_theme=theme.load(args.theme_path)
-config.apply(os.environ["HOME"]+"/.config/i3/config",loaded_theme)
-for meta_key,meta_value in loaded_theme["meta"].items():
- log(meta_value,title=meta_key.title())
-if args.restart:
- subprocess.Popen("i3-msg restart".split(),stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-#######################
+argsExtractParser = argsSubParsers.add_parser("extract")
+argsExtractParser.add_argument('config_path', type=str, nargs='?',
+ help='Extract theme from config file.')
+argsExtractParser.set_defaults(func=extract)
+args = argsMainParser.parse_args()
+args.func(args)
+###########################