From 182bc5bdf78e489a04d2774d83f71ed20d2df5d0 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Wed, 20 Oct 2010 02:12:23 +0200 Subject: play: fixed control FIFO creation --- play | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/play b/play index e17048c..7f66294 100644 --- a/play +++ b/play @@ -64,7 +64,7 @@ except: # ------------------------------------------ XTERM = re.search("rxvt|xterm", os.environ["TERM"]) -CONTROL_FIFO = "/var/tmp/play_control" +CONTROL_FIFO = "%s/play-control-%s" % (os.environ.get("TMPDIR", "/tmp"), os.environ["USER"]) # ------------------------------------------ def which(program): @@ -1361,8 +1361,6 @@ class Timeout: # ------------------------------------------ class FIFOControl: def __init__(self): - try: self.fd = open(CONTROL_FIFO, "rb+", 0) - except: self.fd = None self.commands = { "pause" : [app.toggle_pause, []], "next" : [app.next_song, []], @@ -1377,6 +1375,14 @@ class FIFOControl: "empty" : [app.win_playlist.command_delete_all, []], "quit" : [app.quit, []] } + self.fd = None + try: + if os.path.exists(CONTROL_FIFO): + os.unlink(CONTROL_FIFO) + os.mkfifo(CONTROL_FIFO, 0600) + self.fd = open(CONTROL_FIFO, "rb+", 0) + except IOError: + return def handle_command(self): argv = self.fd.readline().strip().split(" ", 1) @@ -1708,4 +1714,5 @@ for rc in [os.path.expanduser("~/.playrc"), "/etc/playrc"]: except IOError: pass # ------------------------------------------ -if __name__ == "__main__": main() +if __name__ == "__main__": + main() -- cgit v1.2.3