docs: Fixed comments

This commit is contained in:
Dylan Araps 2017-08-01 16:38:22 +10:00
parent 53819ed977
commit b299f7b3fd
6 changed files with 33 additions and 29 deletions

View File

@ -117,7 +117,7 @@ def process_args(args):
reload.env() reload.env()
if args.o: if args.o:
util.disown(args.o) util.disown([args.o])
def main(): def main():

View File

@ -15,9 +15,9 @@ def xrdb(xrdb_file=None):
xrdb_file = xrdb_file or CACHE_DIR / "colors.Xresources" xrdb_file = xrdb_file or CACHE_DIR / "colors.Xresources"
if shutil.which("xrdb"): if shutil.which("xrdb"):
subprocess.call(["xrdb", "-merge", xrdb_file], subprocess.Popen(["xrdb", "-merge", xrdb_file],
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) stderr=subprocess.DEVNULL).wait()
def gtk(): def gtk():
@ -33,7 +33,8 @@ def gtk():
# This is done because the Python 3 GTK/Gdk libraries don't # This is done because the Python 3 GTK/Gdk libraries don't
# provide a way of doing this. # provide a way of doing this.
if shutil.which("python2"): if shutil.which("python2"):
util.disown("python2", MODULE_DIR / "scripts" / "gtk_reload.py") util.disown(["python2", MODULE_DIR / "scripts" / "gtk_reload.py"])
else: else:
print("warning: GTK2 reload support requires Python 2.") print("warning: GTK2 reload support requires Python 2.")
@ -41,7 +42,7 @@ def gtk():
def i3(): def i3():
"""Reload i3 colors.""" """Reload i3 colors."""
if shutil.which("i3-msg"): if shutil.which("i3-msg"):
util.disown("i3-msg", "reload") util.disown(["i3-msg", "reload"])
def polybar(): def polybar():

View File

@ -10,7 +10,7 @@ Original source: https://crunchbang.org/forums/viewtopic.php?id=39646
try: try:
import gtk import gtk
except ImportError: except ImportError:
print("[!] error: GTK reload requires PyGTK.") print("error: GTK reload requires PyGTK.")
exit(1) exit(1)

View File

@ -69,4 +69,4 @@ def send(colors, vte, cache_dir=CACHE_DIR):
util.save_file(sequences, term) util.save_file(sequences, term)
util.save_file(sequences, cache_dir / "sequences") util.save_file(sequences, cache_dir / "sequences")
print("colors: Set terminal colors") print("colors: Set terminal colors.")

View File

@ -119,10 +119,10 @@ def darken_color(color, darkness):
return rgb_to_hex([int(col * (1 - darkness)) for col in hex_to_rgb(color)]) 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, """Call a system command in the background,
disown it and hide it's output.""" disown it and hide it's output."""
subprocess.Popen(["nohup"] + list(cmd), subprocess.Popen(["nohup", *cmd],
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
preexec_fn=os.setpgrp) preexec_fn=os.setpgrp)
@ -132,6 +132,6 @@ def msg(input_msg, notify):
"""Print to the terminal and display a libnotify """Print to the terminal and display a libnotify
notification.""" notification."""
if notify: if notify:
disown("notify-send", input_msg) disown(["notify-send", input_msg])
print(input_msg) print(input_msg)

View File

@ -28,26 +28,26 @@ def get_desktop_env():
def xfconf(path, img): def xfconf(path, img):
"""Call xfconf to set the wallpaper on XFCE.""" """Call xfconf to set the wallpaper on XFCE."""
util.disown("xfconf-query", "--channel", "xfce4-desktop", util.disown(["xfconf-query", "--channel", "xfce4-desktop",
"--property", path, "--set", img) "--property", path, "--set", img])
def set_wm_wallpaper(img): def set_wm_wallpaper(img):
"""Set the wallpaper for non desktop environments.""" """Set the wallpaper for non desktop environments."""
if shutil.which("feh"): if shutil.which("feh"):
subprocess.Popen(["feh", "--bg-fill", img]) util.disown(["feh", "--bg-fill", img])
elif shutil.which("nitrogen"): elif shutil.which("nitrogen"):
subprocess.Popen(["nitrogen", "--set-zoom-fill", img]) util.disown(["nitrogen", "--set-zoom-fill", img])
elif shutil.which("bgs"): elif shutil.which("bgs"):
subprocess.Popen(["bgs", img]) util.disown(["bgs", img])
elif shutil.which("hsetroot"): elif shutil.which("hsetroot"):
subprocess.Popen(["hsetroot", "-fill", img]) util.disown(["hsetroot", "-fill", img])
elif shutil.which("habak"): elif shutil.which("habak"):
subprocess.Popen(["habak", "-mS", img]) util.disown(["habak", "-mS", img])
else: else:
print("error: No wallpaper setter found.") print("error: No wallpaper setter found.")
@ -64,17 +64,17 @@ def set_desktop_wallpaper(desktop, img):
xfconf("/backdrop/screen0/monitor0/workspace0/last-image", img) xfconf("/backdrop/screen0/monitor0/workspace0/last-image", img)
elif "muffin" in desktop or "cinnamon" in desktop: elif "muffin" in desktop or "cinnamon" in desktop:
subprocess.Popen(["gsettings", "set", util.disown(["gsettings", "set",
"org.cinnamon.desktop.background", "org.cinnamon.desktop.background",
"picture-uri", "file://" + img]) "picture-uri", "file://" + img])
elif "gnome" in desktop: elif "gnome" in desktop:
subprocess.Popen(["gsettings", "set", util.disown(["gsettings", "set",
"org.gnome.desktop.background", "org.gnome.desktop.background",
"picture-uri", "file://" + img]) "picture-uri", "file://" + img])
elif "mate" in desktop: elif "mate" in desktop:
subprocess.Popen(["gsettings", "set", "org.mate.background", util.disown(["gsettings", "set", "org.mate.background",
"picture-filename", img]) "picture-filename", img])
else: else:
@ -86,8 +86,11 @@ def set_mac_wallpaper(img):
db_file = HOME / "Library/Application Support/Dock/desktoppicture.db" db_file = HOME / "Library/Application Support/Dock/desktoppicture.db"
subprocess.call(["sqlite3", db_file, f"update data set value = '{img}'"]) subprocess.call(["sqlite3", db_file, f"update data set value = '{img}'"])
# Kill the dock to fix issues with wallpapers sharing names. # Kill the dock to fix issues with cached wallpapers.
util.disown("killall", "Dock") # 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): def change(img):
@ -106,7 +109,7 @@ def change(img):
else: else:
set_wm_wallpaper(img) set_wm_wallpaper(img)
print("wallpaper: Set the new wallpaper") print("wallpaper: Set the new wallpaper.")
def get(cache_dir=CACHE_DIR): def get(cache_dir=CACHE_DIR):