From ac55b37459c0b117a8a609d6e6d342424187402f Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 16 Oct 2015 17:08:29 +0200 Subject: [PATCH] notifyd: call aplay using subprocess.Popen + replace os.system with subprocess.call Closes #2 --- usr_bin/notifyd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr_bin/notifyd.py b/usr_bin/notifyd.py index cf94ee6..28d985c 100755 --- a/usr_bin/notifyd.py +++ b/usr_bin/notifyd.py @@ -47,6 +47,7 @@ import string import socket import logging import getopt +import subprocess default_hostname = 'localhost' default_port = 1234 @@ -58,12 +59,13 @@ default_logfile = None def play(sound_file): def play_wrapper(msg): - os.system('/usr/bin/aplay "%s" 2> /dev/null &' % sound_file) + with open(os.devnull, 'w') as devnull: + subprocess.Popen(['/usr/bin/aplay', sound_file], stderr=devnull) return play_wrapper def execute(command): def command_wrapper(msg): - os.system(command % dict(msg = msg)) + subprocess.call(command % dict(msg = msg)) return command_wrapper def osd(msg): -- 2.1.4