]> git.plutz.net Git - serve0/blobdiff - actions/playctl.sh
workaround for REFERER shy browsers: put referrer in POST data
[serve0] / actions / playctl.sh
index 183bee6fe0cb2ff6d1acc12ce41cdfd564801a6a..55997cad1af59a60c1fc4a4a2c5e1b46a2f4e58c 100755 (executable)
 
 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
@@ -32,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]}"