]> git.plutz.net Git - serve0/blobdiff - actions/playctl.sh
enable some PulseAudio features, put some player controls in extra panel
[serve0] / actions / playctl.sh
index b532e36dfd28202667cb2d02dc490ae1175caad8..6944771f7cea4ac716fd7ef8efbc81ebd6cbd7e2 100755 (executable)
@@ -21,6 +21,9 @@ 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
@@ -33,6 +36,12 @@ 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";\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";;