diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-06-23 14:16:46 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-06-23 14:16:46 +1000 |
| commit | 55314023692cd2c15ef4276d057cbf01072b3c29 (patch) | |
| tree | 3b1e43a6cdc5f64e525b369f5fd57c7af3230796 | |
| parent | 5481829a1299a7b341254a5875ca3973af3737e2 (diff) | |
General: Move duplicate code to a function.
| -rwxr-xr-x | wal | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -119,10 +119,7 @@ def process_args(args): # -o if args.o: - subprocess.Popen(["nohup", args.o], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - preexec_fn=os.setpgrp) + disown(args.o) # }}} @@ -475,10 +472,7 @@ def reload_xrdb(export_file): def reload_i3(): """Reload i3 colors.""" if shutil.which("i3-msg"): - subprocess.Popen(["i3-msg", "reload"], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - preexec_fn=os.setpgrp) + disown("i3-msg", "reload") def export_colors(colors): @@ -570,6 +564,15 @@ def notify(msg): preexec_fn=os.setpgrp) +def disown(*cmd): + """Call a system command in the background, + disown it and hide it's output.""" + subprocess.Popen(["nohup"] + list(cmd), + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + preexec_fn=os.setpgrp) + + # }}} |
