mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-26 15:59:10 +01:00
reload: Check pids first.
This commit is contained in:
parent
7e797405c5
commit
f26a8bbb5e
@ -61,25 +61,25 @@ def gtk():
|
|||||||
|
|
||||||
def i3():
|
def i3():
|
||||||
"""Reload i3 colors."""
|
"""Reload i3 colors."""
|
||||||
if shutil.which("i3-msg"):
|
if shutil.which("i3-msg") and util.get_pid("i3"):
|
||||||
util.disown(["i3-msg", "reload"])
|
util.disown(["i3-msg", "reload"])
|
||||||
|
|
||||||
|
|
||||||
def kitty():
|
def kitty():
|
||||||
""" Reload kitty colors. """
|
""" Reload kitty colors. """
|
||||||
if shutil.which("kitty"):
|
if shutil.which("kitty") and util.get_pid("kitty"):
|
||||||
util.disown(["kitty", "@", "set-colors", "--all"])
|
util.disown(["kitty", "@", "set-colors", "--all"])
|
||||||
|
|
||||||
|
|
||||||
def polybar():
|
def polybar():
|
||||||
"""Reload polybar colors."""
|
"""Reload polybar colors."""
|
||||||
if shutil.which("polybar"):
|
if shutil.which("polybar") and util.get_pid("polybar"):
|
||||||
util.disown(["pkill", "-USR1", "polybar"])
|
util.disown(["pkill", "-USR1", "polybar"])
|
||||||
|
|
||||||
|
|
||||||
def sway():
|
def sway():
|
||||||
"""Reload sway colors."""
|
"""Reload sway colors."""
|
||||||
if shutil.which("swaymsg"):
|
if shutil.which("swaymsg") and util.get_pid("sway"):
|
||||||
util.disown(["swaymsg", "reload"])
|
util.disown(["swaymsg", "reload"])
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,3 +168,11 @@ def disown(cmd):
|
|||||||
subprocess.Popen(cmd,
|
subprocess.Popen(cmd,
|
||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
|
||||||
|
def get_pid(name):
|
||||||
|
"""Check if process is running by name."""
|
||||||
|
try:
|
||||||
|
subprocess.check_output(["pidof", "-s", name])
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user