diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-06-29 20:05:11 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-06-29 20:05:11 +1000 |
| commit | 0834cd024ba0988c9241ee8b64c38c2e0c6337cb (patch) | |
| tree | d9425abbf7b35a64c2e851c8637d5274f529e3be | |
| parent | d9a22726cbb260cae7e7fdaf1fe4b8d69caab80f (diff) | |
general: Remove duplicate code.
| -rwxr-xr-x | pywal/__main__.py | 9 | ||||
| -rw-r--r-- | pywal/reload.py | 27 |
2 files changed, 32 insertions, 4 deletions
diff --git a/pywal/__main__.py b/pywal/__main__.py index 7b516aa..4236267 100755 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -11,6 +11,7 @@ from pywal.settings import CACHE_DIR, __version__ from pywal import export_colors from pywal import gen_colors from pywal import set_colors +from pywal import reload from pywal import wallpaper from pywal import util @@ -94,15 +95,15 @@ def process_args(args): if not args.n: wallpaper.set_wallpaper(image) - # Set the colors. - set_colors.send_sequences(colors_plain, args.t) - export_colors.export_all_templates(colors_plain) - # -f elif args.f: colors_plain = util.read_file_json(args.f) + + # -i or -f + if args.i or args.f: set_colors.send_sequences(colors_plain, args.t) export_colors.export_all_templates(colors_plain) + reload.reload_env() # -o if args.o: diff --git a/pywal/reload.py b/pywal/reload.py new file mode 100644 index 0000000..0c5c612 --- /dev/null +++ b/pywal/reload.py @@ -0,0 +1,27 @@ +""" +Reload programs. +""" +import shutil +import subprocess + +from pywal.settings import CACHE_DIR +from pywal import util + + +def reload_i3(): + """Reload i3 colors.""" + if shutil.which("i3-msg"): + util.disown("i3-msg", "reload") + + +def reload_xrdb(): + """Merge the colors into the X db so new terminals use them.""" + if shutil.which("xrdb"): + subprocess.call(["xrdb", "-merge", CACHE_DIR / "colors.Xresources"]) + + +def reload_env(): + """Reload environment programs.""" + reload_i3() + reload_xrdb() + print("reload: Reloaded environment.") |
