From: paul Date: Mon, 28 Nov 2016 21:31:32 +0000 (+0000) Subject: automatically switch between MPlayer/MPlayer2 X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=50ca23e58b678c818c2a8bb3a345136c1366047a;p=serve0 automatically switch between MPlayer/MPlayer2 svn path=/trunk/; revision=163 --- diff --git a/actions/watch.sh b/actions/watch.sh index cfa5437..8d8ac33 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -64,7 +64,7 @@ case "$_COOKIE[watch]" in fifofile="${_DATA}/mplayer.fifo" statusfile="${_DATA}/mplayer.status" statusfile="/tmp/mplayer.status" - volume="$(validate "$(cat "${_DATA}/mplayer.volume")" '[1-9]?[0-9]|100' 20)" + volume="$(validate "$(cat "${_DATA}/mplayer.volume" || true)" '[1-9]?[0-9]|100' 20)" [ \! -p "$fifofile" ] && rm -f "$fifofile" && mkfifo -m 600 "$fifofile" debug PLAYURI "$playuri" @@ -79,18 +79,19 @@ case "$_COOKIE[watch]" in export DISPLAY=":0" uid="$(id |sed -rn '1s;.*uid=([0-9]+)[^0-9].*;\1;p')" export XDG_RUNTIME_DIR="/run/user/$uid" # required for Pulseaudio - xrandr >/dev/null # helps enable all screens - - # nohup /usr/bin/mplayer \ - # -slave -input file="$fifofile" \ - # -volume "$volume" \ - # "$playuri" >"$statusfile" 2>/dev/null & - - # MPlayer2: (statusline on stderr) - nohup /usr/bin/mplayer \ - --slave --input=file="$fifofile" \ - --volume="$volume" \ - "$playuri" 2>"$statusfile" >/dev/null & + xrandr || true >/dev/null # helps enable all screens + + if mplayer |grep -q MPlayer2; then + nohup /usr/bin/mplayer \ + --slave --input=file="$fifofile" \ + --volume="$volume" \ + "$playuri" 2>"$statusfile" >/dev/null & + else + nohup /usr/bin/mplayer \ + -slave -input file="$fifofile" \ + -volume "$volume" \ + "$playuri" >"$statusfile" 2>/dev/null & + fi chmod 600 "$statusfile"