From ebf8f81ec61c1302d302a42831a4376c6cb8f8cb Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 22 Aug 2016 12:51:11 +0000 Subject: [PATCH] enable some PulseAudio features, put some player controls in extra panel svn path=/trunk/; revision=144 --- actions/playctl.sh | 9 ++++ pages/playctl.sh | 8 +++ static/common.css | 38 +++++++------- templates/playctl.html.sh | 108 +++++++++++++++++++++----------------- 4 files changed, 97 insertions(+), 66 deletions(-) diff --git a/actions/playctl.sh b/actions/playctl.sh index b532e36..6944771 100755 --- a/actions/playctl.sh +++ b/actions/playctl.sh @@ -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";; diff --git a/pages/playctl.sh b/pages/playctl.sh index 16e67a5..eb75304 100755 --- a/pages/playctl.sh +++ b/pages/playctl.sh @@ -37,6 +37,14 @@ volume=$(validate "$(cat "$_DATA/mplayer.volume")" '[1-9]?[0-9]|100' 20) debug VIDEO: $video +pa_sinks(){ + export DISPLAY=":0" + export XDG_RUNTIME_DIR="/run/user/$(id |sed -rn '1s;.*uid=([0-9]+)[^0-9].*;\1;p')" + + pactl list sinks \ + | sed -rn '/Sink #/{:X;N;/Description: /!bX;s;Sink #([0-9]+).+Description: (.*);\1 \2;p}' +} + printf 'Refresh: 1\r\n' progress(){ diff --git a/static/common.css b/static/common.css index 858a1be..6ccd0c2 100644 --- a/static/common.css +++ b/static/common.css @@ -362,36 +362,38 @@ p.quicklinks input:checked + a { display: none;} width: 100%; } -#playctl form fieldset { +form.playctl fieldset { display: block; position: relative; width: 100%; border: none; text-align: center; } -#playctl form fieldset.playback { height: 12em; } -#playctl form fieldset.playback button { +form.playctl fieldset.playback { height: 12em; } +form.playctl fieldset.playback button { position: absolute; height: 6em; padding-top: 1em; background-color: #EEE; border: 1px solid #333; } -#playctl form fieldset.playback button[value="-60"] {top: 6em; left: 0; width: 20%;} -#playctl form fieldset.playback button[value="-10"] {top: 6em; left: 20%; width: 30%;} -#playctl form fieldset.playback button[value="stop"] {top: 0; left: 0; width: 40%;} -#playctl form fieldset.playback button[value="pause"] {top: 0; right: 0; width: 60%;} -#playctl form fieldset.playback button[value="+10"] {top: 6em; right: 20%; width: 30%;} -#playctl form fieldset.playback button[value="+60"] {top: 6em; right: 0; width: 20%;} - -#playctl form fieldset.volume { height: 7em; } -#playctl form fieldset.volume button[name="amp"] {position: absolute; width: 50%; height: 4em; top: 0;} -#playctl form fieldset.volume button[value="off"] {left:0;} -#playctl form fieldset.volume button[value="on"] {right:0;} -#playctl form fieldset.volume button[name="vol"] {position: relative; display: inline-block; top: 5em; width: 4%;} -#playctl form fieldset.volume button[name="vol"].selected { background-color: #FA6;} -#playctl form fieldset.volume button[name="vol"][value="100"], -#playctl form fieldset.volume button[name="vol"][value="0"] { width: 4%;} +form.playctl fieldset.playback button[value="-60"] {top: 6em; left: 0; width: 20%;} +form.playctl fieldset.playback button[value="-10"] {top: 6em; left: 20%; width: 30%;} +form.playctl fieldset.playback button[value="stop"] {top: 0; left: 0; width: 40%;} +form.playctl fieldset.playback button[value="pause"] {top: 0; right: 0; width: 60%;} +form.playctl fieldset.playback button[value="+10"] {top: 6em; right: 20%; width: 30%;} +form.playctl fieldset.playback button[value="+60"] {top: 6em; right: 0; width: 20%;} + +form.playctl fieldset.volume { height: 3em; } +form#advctl.playctl fieldset.volume { height: 4em; } +form.playctl fieldset.volume button[name="amp"] {position: absolute; width: 50%; height: 4em; top: 0;} +form.playctl fieldset.volume button[value="off"] {left:0;} +form.playctl fieldset.volume button[value="on"] {right:0;} +form.playctl fieldset.volume button[name="vol"] {position: relative; display: inline-block; width: 4%;} +form.playctl fieldset.volume button[name="vol"].selected { background-color: #FA6;} +form.playctl fieldset.volume button[name="vol"][value="100"], +form.playctl fieldset.volume button[name="vol"][value="0"] { width: 4%;} +form.playctl fieldset.pasink button { width: 100%; height: 3em;} span.progress { display: block; diff --git a/templates/playctl.html.sh b/templates/playctl.html.sh index ec6467e..6bf7dcc 100755 --- a/templates/playctl.html.sh +++ b/templates/playctl.html.sh @@ -35,22 +35,20 @@ cat <$info Download -
-
- - - - - - -
-
- - - $(for n in $(seq 0 5 100); do - printf '' "$([ "$volume" = "$n" ] && printf selected)" "$n" - done) -
+ +
+ + + + + + +
+
+ $(for n in $(seq 0 5 100); do + printf '' "$([ "$volume" = "$n" ] && printf selected)" "$n" + done) +
$(printf "%d:%02d min" $(($length / 60)) $(($length % 60)) ) @@ -59,46 +57,60 @@ cat <\1 :g') ${description:+$(printf %s "$description" |_wiki)} + -
- - - - - $( - for cat in $(list_categories); do - printf '

' - done - ) + +
+ + +
+
+ $(pa_sinks |while read no name; do + printf '' "$no" "$name" + done) +
+ Hide +
-

- - -

-

- - -

- - +
+ + + - Hide + $( + for cat in $(list_categories); do + printf '

' + done + ) -
- +

+ + +

+

+ + +

+ + + + Hide + + EOF -- 2.39.2