TOOLS/umpv: allow passing options

But only via a special environment variable.
This commit is contained in:
wm4
2014-04-30 11:45:32 +02:00
parent f3eb5b143c
commit d7538d3597
+14 -2
View File
@@ -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)