Files
playground/mpv_pip
T
2026-07-25 09:09:40 +02:00

25 lines
536 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
MPV=/opt/homebrew/bin/mpv
if [[ $# -eq 0 ]]; then
echo "Usage: $(basename "$0") <file|url> [file|url ...]" >&2
echo " $(basename "$0") mpv://open?url=<url-encoded target>" >&2
exit 1
fi
TARGETS=()
for arg in "$@"; do
if [[ "$arg" == mpv://* ]]; then
arg=$(python3 -c '
import sys, urllib.parse as u
q = u.parse_qs(u.urlparse(sys.argv[1]).query)
print(q["url"][0])
' "$arg")
fi
TARGETS+=("$arg")
done
"$MPV" --ontop --on-all-workspaces --volume=0 "${TARGETS[@]}" &