Skip to content

Instantly share code, notes, and snippets.

@keizie
Created February 15, 2020 20:40
Show Gist options
  • Save keizie/c3eff2d9ebb94ebbdec7ec3b25ccaa53 to your computer and use it in GitHub Desktop.
Save keizie/c3eff2d9ebb94ebbdec7ec3b25ccaa53 to your computer and use it in GitHub Desktop.
bash clone of python umpv from mpv package
#!/bin/bash
FIFO="/tmp/mpvpipe"
TARGET=$1
if [ "x--" = "x$TARGET" ]; then
TARGET=$2
fi
PID=$(fuser $FIFO 2> /dev/null)
if [ $? -ne 0 ]; then
OPTS=""
exec mpv --player-operation-mode=pseudo-gui --idle=once --input-ipc-server=$FIFO $OPTS "$@" &
else
echo '{ "command": ["write-watch-later-config"] }' | socat - $FIFO
OPTS=""
#OPTS="video-rotate=0,video-zoom=0"
echo '{ "command": ["loadfile", "'$TARGET'", "replace", "'$OPTS'"] }' | socat - $FIFO
[ $? -eq 0 ] && wmctrl -p -l | grep $PID | cut -d\ -f1 | xargs wmctrl -iR
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment