X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=actions%2Fplayctl.sh;h=55997cad1af59a60c1fc4a4a2c5e1b46a2f4e58c;hb=228ce4d69eee3b68047a610fc907a0ec05ebc19a;hp=38cd54ccdbc8b714a71c085cdae1404bb3a15184;hpb=623e13703a176cf67053c5e21a6d2c71f5a96c55;p=serve0 diff --git a/actions/playctl.sh b/actions/playctl.sh index 38cd54c..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,6 +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]}"