diff --git a/pywal/__main__.py b/pywal/__main__.py index de302d6..460d77b 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -117,7 +117,7 @@ def process_args(args): reload.env() if args.o: - util.disown(args.o) + util.disown([args.o]) def main(): diff --git a/pywal/reload.py b/pywal/reload.py index 3e7a6c3..56c2c8e 100644 --- a/pywal/reload.py +++ b/pywal/reload.py @@ -15,9 +15,9 @@ def xrdb(xrdb_file=None): xrdb_file = xrdb_file or CACHE_DIR / "colors.Xresources" if shutil.which("xrdb"): - subprocess.call(["xrdb", "-merge", xrdb_file], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + subprocess.Popen(["xrdb", "-merge", xrdb_file], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL).wait() def gtk(): @@ -33,7 +33,8 @@ def gtk(): # This is done because the Python 3 GTK/Gdk libraries don't # provide a way of doing this. if shutil.which("python2"): - util.disown("python2", MODULE_DIR / "scripts" / "gtk_reload.py") + util.disown(["python2", MODULE_DIR / "scripts" / "gtk_reload.py"]) + else: print("warning: GTK2 reload support requires Python 2.") @@ -41,7 +42,7 @@ def gtk(): def i3(): """Reload i3 colors.""" if shutil.which("i3-msg"): - util.disown("i3-msg", "reload") + util.disown(["i3-msg", "reload"]) def polybar(): diff --git a/pywal/scripts/gtk_reload.py b/pywal/scripts/gtk_reload.py index e17b93b..ffb267d 100644 --- a/pywal/scripts/gtk_reload.py +++ b/pywal/scripts/gtk_reload.py @@ -10,7 +10,7 @@ Original source: https://crunchbang.org/forums/viewtopic.php?id=39646 try: import gtk except ImportError: - print("[!] error: GTK reload requires PyGTK.") + print("error: GTK reload requires PyGTK.") exit(1) diff --git a/pywal/sequences.py b/pywal/sequences.py index cf5aae7..bbe7c72 100644 --- a/pywal/sequences.py +++ b/pywal/sequences.py @@ -69,4 +69,4 @@ def send(colors, vte, cache_dir=CACHE_DIR): util.save_file(sequences, term) util.save_file(sequences, cache_dir / "sequences") - print("colors: Set terminal colors") + print("colors: Set terminal colors.") diff --git a/pywal/util.py b/pywal/util.py index 2f86811..2f5debc 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -119,10 +119,10 @@ def darken_color(color, darkness): return rgb_to_hex([int(col * (1 - darkness)) for col in hex_to_rgb(color)]) -def disown(*cmd): +def disown(cmd): """Call a system command in the background, disown it and hide it's output.""" - subprocess.Popen(["nohup"] + list(cmd), + subprocess.Popen(["nohup", *cmd], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setpgrp) @@ -132,6 +132,6 @@ def msg(input_msg, notify): """Print to the terminal and display a libnotify notification.""" if notify: - disown("notify-send", input_msg) + disown(["notify-send", input_msg]) print(input_msg) diff --git a/pywal/wallpaper.py b/pywal/wallpaper.py index 05f5d08..dae0f24 100644 --- a/pywal/wallpaper.py +++ b/pywal/wallpaper.py @@ -28,26 +28,26 @@ def get_desktop_env(): def xfconf(path, img): """Call xfconf to set the wallpaper on XFCE.""" - util.disown("xfconf-query", "--channel", "xfce4-desktop", - "--property", path, "--set", img) + util.disown(["xfconf-query", "--channel", "xfce4-desktop", + "--property", path, "--set", img]) def set_wm_wallpaper(img): """Set the wallpaper for non desktop environments.""" if shutil.which("feh"): - subprocess.Popen(["feh", "--bg-fill", img]) + util.disown(["feh", "--bg-fill", img]) elif shutil.which("nitrogen"): - subprocess.Popen(["nitrogen", "--set-zoom-fill", img]) + util.disown(["nitrogen", "--set-zoom-fill", img]) elif shutil.which("bgs"): - subprocess.Popen(["bgs", img]) + util.disown(["bgs", img]) elif shutil.which("hsetroot"): - subprocess.Popen(["hsetroot", "-fill", img]) + util.disown(["hsetroot", "-fill", img]) elif shutil.which("habak"): - subprocess.Popen(["habak", "-mS", img]) + util.disown(["habak", "-mS", img]) else: print("error: No wallpaper setter found.") @@ -64,18 +64,18 @@ def set_desktop_wallpaper(desktop, img): xfconf("/backdrop/screen0/monitor0/workspace0/last-image", img) elif "muffin" in desktop or "cinnamon" in desktop: - subprocess.Popen(["gsettings", "set", - "org.cinnamon.desktop.background", - "picture-uri", "file://" + img]) + util.disown(["gsettings", "set", + "org.cinnamon.desktop.background", + "picture-uri", "file://" + img]) elif "gnome" in desktop: - subprocess.Popen(["gsettings", "set", - "org.gnome.desktop.background", - "picture-uri", "file://" + img]) + util.disown(["gsettings", "set", + "org.gnome.desktop.background", + "picture-uri", "file://" + img]) elif "mate" in desktop: - subprocess.Popen(["gsettings", "set", "org.mate.background", - "picture-filename", img]) + util.disown(["gsettings", "set", "org.mate.background", + "picture-filename", img]) else: set_wm_wallpaper(img) @@ -86,8 +86,11 @@ def set_mac_wallpaper(img): db_file = HOME / "Library/Application Support/Dock/desktoppicture.db" subprocess.call(["sqlite3", db_file, f"update data set value = '{img}'"]) - # Kill the dock to fix issues with wallpapers sharing names. - util.disown("killall", "Dock") + # Kill the dock to fix issues with cached wallpapers. + # macOS caches wallpapers and if a wallpaper is set that shares + # the filename with a cached wallpaper, the cached wallpaper is + # used instead. + util.disown(["killall", "Dock"]) def change(img): @@ -106,7 +109,7 @@ def change(img): else: set_wm_wallpaper(img) - print("wallpaper: Set the new wallpaper") + print("wallpaper: Set the new wallpaper.") def get(cache_dir=CACHE_DIR):