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"
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"