From d7538d359705c3de5ea158f42fdd8721b4708809 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 29 Apr 2014 01:23:44 +0200 Subject: TOOLS/umpv: allow passing options But only via a special environment variable. --- TOOLS/umpv | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/TOOLS/umpv b/TOOLS/umpv index 300e6334a3..5f867ce5fe 100755 --- a/TOOLS/umpv +++ b/TOOLS/umpv @@ -23,6 +23,11 @@ Note that you can control the mpv instance by writing to the command fifo: echo "cycle fullscreen" > /tmp/umpv-fifo-* +Note: you can supply custom options with the UMPV_OPTIONS environment variable. + The environment variable will be split on whitespace, and each item is + passed as option to mpv _if_ the script starts mpv. If mpv is not started + by the script (i.e. mpv is already running), the options will be ignored. + Warning: The script attempts to make sure the FIFO is safely created (i.e. not world- @@ -46,6 +51,9 @@ files = sys.argv[1:] # make them absolute; also makes them safe against interpretation as options files = [os.path.abspath(f) for f in files] +opts_env = os.getenv("UMPV_OPTIONS") +opts_env = opts_env.split() if opts_env else [] + FIFO = "/tmp/umpv-fifo-" + os.getenv("USER") fifo_fd = -1 @@ -89,5 +97,9 @@ else: raise e os.mkfifo(FIFO, int("0600", 8)) - subprocess.check_call(["mpv", "--really-quiet", "--force-window", - "--input-file=" + FIFO, "--"] + files) + opts = ["mpv", "--really-quiet", "--force-window", "--input-file=" + FIFO] + opts.extend(opts_env) + opts.append("--") + opts.extend(files) + + subprocess.check_call(opts) -- cgit v1.2.3