diff options
-rwxr-xr-x | modules/espeak | 24 | ||||
-rwxr-xr-x | modules/help | 24 | ||||
-rwxr-xr-x | modules/lang | 22 | ||||
-rwxr-xr-x | modules/msg | 6 | ||||
-rwxr-xr-x | modules/play | 32 | ||||
-rwxr-xr-x | modules/wall | 9 | ||||
-rwxr-xr-x | modules/zeit | 19 | ||||
-rwxr-xr-x | noise | 121 | ||||
-rwxr-xr-x | noise-as-shack | 4 | ||||
-rwxr-xr-x | noise-server | 4 |
10 files changed, 265 insertions, 0 deletions
diff --git a/modules/espeak b/modules/espeak new file mode 100755 index 00000000..1f5c901d --- /dev/null +++ b/modules/espeak @@ -0,0 +1,24 @@ +#! /bin/sh + +print_var() { + echo "[35;4m$1[;35m = [32m$2[m" +} + +case "$1" in + (--help) echo say something with espeak ;; + (*) + p="${noise_pitch-100}" + v="${noise_lang-de}" + k="${noise_capital-0}" + a="${noise_amplitude-100}" + g="${noise_gap-1}" + print_var pitch $p + print_var lang $v + print_var capital $k + print_var amplitude $a + print_var gap $g + #echo "[31mespeak -p \"$pitch\" -v \"$lang\" \"$*\"[m" >&2 + espeak -a $a -k $k -p $p -v $v -g $g<<EOF +$* +EOF +esac diff --git a/modules/help b/modules/help new file mode 100755 index 00000000..48c06686 --- /dev/null +++ b/modules/help @@ -0,0 +1,24 @@ +#! /bin/sh +case "$1" in + (-*) : ;; # ignore all options + ('') { for directory in `echo "$NOISE_PATH" | tr : \ ` ; do + for module in "$directory"/* ; do + echo `basename "$module"` `$module --help` + done + done + ## print all documented built-in commands + sed -rn 's:^noise_([a-z]+)\(\) \{ # (.+)?$:\1 \2:p' "$NOISE" + } | sort | sed -rn ' + $s/$/[m/ + s:^([a-z]+) (.+):[35mtype [32m/\1[35m to \2:p' ;; + (*) + ## call + for directory in `echo "$NOISE_PATH" | tr : \ ` ; do + for module in "$directory/$1" ; do + if test -e $module ; then + shift + exec $module --help --verbose "$@" 2>&1 + fi + done + done +esac diff --git a/modules/lang b/modules/lang new file mode 100755 index 00000000..07b6802e --- /dev/null +++ b/modules/lang @@ -0,0 +1,22 @@ +#! /bin/sh + +case "$1" in + (--help) + echo "set language or list available languages" ;; + (list) + espeak --voices | sed -n '1!p' | awk '{\ + printf"[32m/lang %s [0;35mset [4mlang[0;35m to %s[m\n",$2,$4 + }' ;; + ('') + echo /set lang >$NOISE_linefeed ;; + (*) + if test -z "$2" ; then + echo /set lang "$1" + else + echo /set lang "$1" + shift + echo "$*" + echo /set lang "${noise_lang-de}" + fi >$NOISE_linefeed +esac + diff --git a/modules/msg b/modules/msg new file mode 100755 index 00000000..344dd963 --- /dev/null +++ b/modules/msg @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + echo "$*" +esac diff --git a/modules/play b/modules/play new file mode 100755 index 00000000..dcb8749f --- /dev/null +++ b/modules/play @@ -0,0 +1,32 @@ +#! /bin/sh +case "$1" in + (--help) + echo "play an audio file" ;; + (*) + exec 2>&1 + ffs='wav mp3 ogg asf flac' + + if test -z "$*" ; then + ls $HOME/noise/samples | sed -r ' + s:\.('"`echo "$ffs" | tr \ \|`"')$: [30m\1[m: + s:^:/play : + s:.*:[32m&[m: + ' + else + for i in $ffs ; do + f=$HOME/noise/samples/$1.$i + test -f "$f" && + case "$i" in + wav) aplay "$f" & ;; + *) mplayer "$f" & ;; + esac && break + done || cat<<EOF +[33m\ +Keine Audiodatei mit dem Namen [4m$1[;33m.EXT gefunden... \ +am besten gleich uploaden: +$ scp NAME $LOGNAME@shack:noise/samples/ + +folgende Dateiendungen werden erkannt: $ffs[m +EOF + fi +esac diff --git a/modules/wall b/modules/wall new file mode 100755 index 00000000..fa7618fe --- /dev/null +++ b/modules/wall @@ -0,0 +1,9 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (?*) + for client in /tmp/noise-client-* ; do + #echo /msg "$*`printf '\a'`" >$client + echo /msg "$*" >$client + done +esac diff --git a/modules/zeit b/modules/zeit new file mode 100755 index 00000000..340d6fce --- /dev/null +++ b/modules/zeit @@ -0,0 +1,19 @@ +#! /bin/sh + +case "$1" in + (--help) + echo "say current time" ;; + (*) + exec >>$NOISE_linefeed + eval `date +'k=%k ; M=%M'` + M=`echo $M | sed 's/0*//'` + echo /set pitch 10 + case "$lang" in + (de|'') echo " Es ist $k Uhr $M" >$NOISE_linefeed ;; + (en|*-en) + test -z "$M" || M="and $M minutes" + echo " It is $k o clock $M" >$NOISE_linefeed ;; + (*) echo "[31mError: unsupported [4mlang[0;31m = $lang[m" >&2 + esac + echo /set pitch ${noise_pitch-100} +esac 2>&1 @@ -0,0 +1,121 @@ +#! /bin/sh + +noise_set() { # set a variable + case "$1" in + (-q|--quiet) echo=: ; shift ;; + (*) echo=echo ;; + esac + case $# in + (0) ## print all noise variables + env | sed -rn ' + s/^noise_([[:alnum:]_]+)=(.*)$/[35;4m\1[;35m = [32m\2[m/p + ' | sort + ;; + (1) ## print value the specified variable + eval "echo \"[35;4m$1[0;35m = [0;32m\$noise_$1[m\"" + ;; + (*) ## set the specified variable + if echo "$1" | grep -q '[^[:alnum:]_]' ; then + fail invalid variable name "[4m$1" + return 23 + fi + eval "old=\"\$noise_$1\"" + if test "x$old" = "x$2" ; then + eval "$echo \"[35;4m$1[0;35m is already [0;32m$2[m\"" + elif test -z "$old" ; then + eval "export noise_$1='$2' ; $echo \ +\"[35;4m$1[0;35m set to [0;32m$2[m\"" + else + eval "export noise_$1='$2' ; $echo \ +\"[35;4m$1[0;35m changed from $old to [0;32m$2[m\"" + fi + ;; + esac +} + +noise_quit() { # exit + echo "[35mGood bye![m" + exit +} + +fail() { + echo "[31mFAIL: $*[m" + return 23 +} + +cleanup() { + rm -f $linefeed + kill $jobs +} + + +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +if test -d "$dirname/modules" ; then + export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$dirname/modules" + export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$HOME/noise/modules" +fi +linefeed="/tmp/noise-client-$$" +trap cleanup EXIT +mkfifo $linefeed +## +## +## +readline() { + { read && echo "$REPLY" ; } | sed -rn " + s/[']//g + s:^/([a-z]+)([[:space:]]+(.*))?$:command=\1; args='\3';:p;t + s@^([[:alnum:]_/+-]+):[[:space:]]*(.*)@command=lang; args='\1 \2';@p;t + s@^\![[:space:]]*(.*)@command=play; args='\1';@p;t + s:.*:command='$noise_default_command'; args='&';:p;t + " +} +## +## +## +export noise_prompt="[30mREADY.[m +" +export noise_default_command=espeak +## +## +## +while echo -n "$noise_prompt" && eval "`readline`" ; do + ## modcall + for dir in `echo "$NOISE_PATH" | tr : \ ` ; do + module="$dir/$command" + if test -x "$module" ; then + shift + eval 'NOISE="$0" NOISE_linefeed="$linefeed" "$module"' "$args" + continue 2 + fi + done + ## funcall + if type noise_$command &>/dev/null ; then + eval 'noise_$command' "$args" + continue + fi + ## + fail unknown command "[4m$command[m" +done <$linefeed & +jobs="${jobs+$jobs }`jobs -p`" +## +## +## +cat<<EOF +[35mwelcome to [4mSHACK UTTERANCE[;35m version 0.9 beta 2 +get help with [32m/help[m +[33mTIP: benutze [4mrlwrap[;33m für eine elitäre Kommandozeile.[m +EOF +## +## +## +exec >>$linefeed +while read ; do + case $REPLY in + (/quit) echo /quit ; exit ;; + (*) tr \; \\n | grep . ;; + esac<<EOF +$REPLY +EOF +done +#### end of file. diff --git a/noise-as-shack b/noise-as-shack new file mode 100755 index 00000000..c327bb81 --- /dev/null +++ b/noise-as-shack @@ -0,0 +1,4 @@ +#! /bin/sh +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +exec su - shack -c "$dirname"/noise diff --git a/noise-server b/noise-server new file mode 100755 index 00000000..2012bbb5 --- /dev/null +++ b/noise-server @@ -0,0 +1,4 @@ +#! /bin/sh +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +exec tcpserver -c 423 -t 2 -D 0.0.0.0 23 "$dirname/noise-as-shack" |