X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=actions%2Fplayctl.sh;h=55997cad1af59a60c1fc4a4a2c5e1b46a2f4e58c;hb=5b28c95408ac219fa5abf790eda7c937542d4e7d;hp=bda4d1b208c9b94a5b4152c17514f1494d2a7097;hpb=ede7b5bc5379c40a8351f3a01b8f4f2a52711d7d;p=serve0 diff --git a/actions/playctl.sh b/actions/playctl.sh index bda4d1b..55997ca 100755 --- a/actions/playctl.sh +++ b/actions/playctl.sh @@ -17,8 +17,15 @@ # along with Serve0 If not, see . fifofile="${_DATA}/mplayer.fifo" +statusfile="${_DATA}/mplayer.status" +statusfile="/tmp/mplayer.status" volfile="${_DATA}/mplayer.volume" +export DISPLAY=":0" +export XDG_RUNTIME_DIR="/run/user/$(id |sed -rn '1s;.*uid=([0-9]+)[^0-9].*;\1;p')" + +printf '\rBREAK\r' >> "$statusfile" + if [ -n "${_POST[amp]+x}" ]; then amp $(validate "${_POST[amp]}" '(on|off)' off) elif [ -n "${_POST[vol]+x}" ]; then @@ -29,10 +36,16 @@ elif [ -n "${_POST[ctl]+x}" ]; then printf '%s\n' $(validate "${_POST[ctl]}" "pause|stop" pause) >"$fifofile" elif [ -n "${_POST[seek]+x}" ]; then printf 'seek %s\n' $(validate "${_POST[seek]}" "[+-]?[0-9]+" 0) >"$fifofile" +elif [ -n "${_POST[pasink]+x}" ]; then + stream="$(\ + pactl list sink-inputs \ + | sed -rn '/Sink Input #/{:X;N;/application.name =/!bX;s;Sink Input #([0-9]+).+application.name = "(MPlayer|mplayer2)";\1;p}' \ + )" + pactl move-sink-input "$stream" "${_POST[pasink]}" elif [ -n "${_POST[osd]+x}" ]; then case ${_POST[osd]} in progression) printf "osd_show_progression\\n";; esac >"$fifofile" fi & -redirect "$HTTP_REFERER" +redirect "${_POST[referrer]}"