diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-10-20 02:12:23 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-10-20 02:12:23 +0200 |
commit | 182bc5bdf78e489a04d2774d83f71ed20d2df5d0 (patch) | |
tree | 635f87449cbaf59e84e52e7cc1950ca468545b61 | |
parent | 1f6823d0d34bdb9cc057140b867218ac953f21ec (diff) | |
download | play-182bc5bdf78e489a04d2774d83f71ed20d2df5d0.tar.xz |
play: fixed control FIFO creation
-rw-r--r-- | play | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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() |