From d6100bee4f47b85e9c64cfb5be6e033055af5b41 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 26 Dec 2011 20:53:03 -0500 Subject: [PATCH] expand vlc-rc helper --- .bin/vlc-rc | 70 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/.bin/vlc-rc b/.bin/vlc-rc index f52e6cf..1b9e856 100755 --- a/.bin/vlc-rc +++ b/.bin/vlc-rc @@ -2,16 +2,30 @@ exec 3<> /dev/tcp/vapier/8001 send() { echo "$*" 1>&3 ; } -recv() { local l; read l <&3; echo ${l%$'\r'} ; } +recv() { local l; read l <&3; echo ${l%$'\r'} | sed 's:\r$::' ; } + +shell() { + cat <&3 & + trap "kill $!" 0 + send "${*:-help}" + sleep 1 + while read -p "vlc$ " -e l ; do + [[ -z $l ]] && continue + case $l in + "?") l="help" ;; + esac + send "$l" + case $l in + quit) break ;; + esac + sleep 1 + done +} case $1 in f|fullscreen) send f $2 ;; -help) - send $1 - cat <&3 - ;; pause|quit) send $1 ;; @@ -20,15 +34,47 @@ vol) send vol$* ;; seek) - off=( 0 5 15 30 60 ) - [[ -z $2 || -n ${2//[-+]} ]] && exit 0 - off=${off[${#2}]} - send get_time - curr=$(recv) - send seek $(( curr ${2:0:1} off )) + if [[ -n $2 && -z ${2//[-+]} ]] ; then + off=( 0 5 15 30 60 ) + off=${off[${#2}]} + send get_time + curr=$(recv) + set -- seek $(( curr ${2:0:1} off )) + send "$@" + else + shell "$@" + fi + ;; +strack) + if [[ $2 == "n" ]] ; then + set -f + send strack + e="+----[ end of Subtitles Track ]" + while l=$(recv) ; do + set -- $l + if [[ $l == "$e" ]] ; then + break + elif [[ $l == "| "* ]] ; then + [[ -z $s ]] && s=$2 + if [[ $l == *" *" ]] ; then + l=$(recv) + if [[ $l != "$e" ]] ; then + set -- $l + s=$2 + fi + break + fi + fi + done + kdialog --msgbox "$l" & + set -- strack $s + send "$@" + else + shell "$@" + fi ;; *) - send "$@" + shell "$@" ;; esac -- 2.39.5