]> git.wh0rd.org Git - home.git/commitdiff
expand vlc-rc helper
authorMike Frysinger <vapier@gentoo.org>
Tue, 27 Dec 2011 01:53:03 +0000 (20:53 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 28 Apr 2012 19:36:42 +0000 (15:36 -0400)
.bin/vlc-rc

index f52e6cf46497375be76c1276dd3647ed5cad8c4f..1b9e856dcb6379b81d59fe3f44ca5705f355dd95 100755 (executable)
@@ -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