summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmodules/date6
-rwxr-xr-xmodules/echo6
-rwxr-xr-xmodules/espeak24
-rwxr-xr-xmodules/help24
-rwxr-xr-xmodules/lang22
-rwxr-xr-xmodules/play32
-rwxr-xr-xmodules/sleep10
-rwxr-xr-xmodules/wall8
-rwxr-xr-xmodules/zeit19
-rwxr-xr-xnoise137
-rwxr-xr-xnoise-as-shack4
-rwxr-xr-xnoise-server4
12 files changed, 296 insertions, 0 deletions
diff --git a/modules/date b/modules/date
new file mode 100755
index 00000000..8cd1b0c1
--- /dev/null
+++ b/modules/date
@@ -0,0 +1,6 @@
+#! /bin/sh
+case "$1" in
+ (--help) : ;;
+ (*)
+ date --rfc-3339=s
+esac
diff --git a/modules/echo b/modules/echo
new file mode 100755
index 00000000..344dd963
--- /dev/null
+++ b/modules/echo
@@ -0,0 +1,6 @@
+#! /bin/sh
+case "$1" in
+ (--help) : ;;
+ (*)
+ echo "$*"
+esac
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 "$1 = $2"
+}
+
+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 "espeak -p \"$pitch\" -v \"$lang\" \"$*\"" >&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/$//
+ s:^([a-z]+) (.+):type /\1 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"/lang %s set lang to %s\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/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 \ \|`"')$: \1:
+ s:^:/play :
+ s:.*:&:
+ '
+ 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
+\
+Keine Audiodatei mit dem Namen $1.EXT gefunden... \
+am besten gleich uploaden:
+$ scp NAME $LOGNAME@shack:noise/samples/
+
+folgende Dateiendungen werden erkannt: $ffs
+EOF
+ fi
+esac
diff --git a/modules/sleep b/modules/sleep
new file mode 100755
index 00000000..b8d350f7
--- /dev/null
+++ b/modules/sleep
@@ -0,0 +1,10 @@
+#! /bin/sh
+case "$1" in
+ (--help) echo "pause for NUMBER seconds" ;;
+ (*)
+ if ! echo "$1" | grep -Eq '^([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)$' ; then
+ echo 'FAIL: $1 is not a number'
+ else
+ sleep "$1"
+ fi
+esac
diff --git a/modules/wall b/modules/wall
new file mode 100755
index 00000000..7c32d01d
--- /dev/null
+++ b/modules/wall
@@ -0,0 +1,8 @@
+#! /bin/sh
+case "$1" in
+ (--help) : ;;
+ (?*)
+ for linefeed in /tmp/noise/*/linefeed ; do
+ echo /msg "$*" >$linefeed
+ done
+esac
diff --git a/modules/zeit b/modules/zeit
new file mode 100755
index 00000000..4c41fa10
--- /dev/null
+++ b/modules/zeit
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+case "$1" in
+ (--help)
+ echo "say current time" ;;
+ (*)
+ exec >>$NOISE_linefeed
+ k=`date +%k`
+ M=`date +%M|sed 's/0*//'`
+ echo /set pitch 10
+ case "$lang" in
+ (de|'') echo "/espeak Es ist $k Uhr $M" ;;
+ (en|*-en)
+ test -z "$M" || M="and $M minutes"
+ echo "/espeak It is $k o clock $M" ;;
+ (*) echo "Error: unsupported lang = $lang" >&2
+ esac
+ echo /set pitch ${noise_pitch-100}
+esac 2>&1
diff --git a/noise b/noise
new file mode 100755
index 00000000..f979c34c
--- /dev/null
+++ b/noise
@@ -0,0 +1,137 @@
+#! /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:]_]+)=(.*)$/\1 = \2/p
+ ' | sort
+ ;;
+ (1) ## print value the specified variable
+ eval "echo \"$1 = \$noise_$1\""
+ ;;
+ (*) ## set the specified variable
+ if echo "$1" | grep -q '[^[:alnum:]_]' ; then
+ fail invalid variable name "$1"
+ return 23
+ fi
+ eval "old=\"\$noise_$1\""
+ if test "x$old" = "x$2" ; then
+ eval "$echo \"$1 is already $2\""
+ elif test -z "$old" ; then
+ eval "export noise_$1='$2' ; $echo \
+\"$1 set to $2\""
+ else
+ eval "export noise_$1='$2' ; $echo \
+\"$1 changed from $old to $2\""
+ fi
+ ## write variable to $env
+ if grep -q "^$1=" "$env" ; then
+ sed -ri "s'^($1)=(.*)\$'\1=\'$2\''" $env
+ else
+ echo "$1='$2'" >>$env
+ fi
+ ;;
+ esac
+}
+
+noise_quit() { # exit
+ echo "Good bye!"
+ exit
+}
+
+fail() {
+ echo "FAIL: $*"
+ return 23
+}
+
+cleanup() {
+ kill $jobs
+ rm -f $linefeed $env
+ rmdir /tmp/noise/$$ 2>/dev/null
+ rmdir /tmp/noise 2>/dev/null
+}
+
+
+qname="`readlink -f "$0"`"
+dirname="`dirname "$qname"`"
+export HOME='/home/shack'
+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
+mkdir -vp /tmp/noise/$$
+linefeed="/tmp/noise/$$/linefeed"
+env="/tmp/noise/$$/environment"
+trap cleanup EXIT
+mkfifo $linefeed
+touch $env
+##
+##
+##
+readline() {
+ { read && echo "$REPLY" ; } | sed -rn "
+ s/[']//g
+ s/~%/\n/g
+ s/([^\\])#/\1\\\\#/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
+ "
+}
+##
+##
+##
+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_pid="$$" 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 "$command"
+done <$linefeed &
+jobs="${jobs+$jobs }`jobs -p`"
+##
+##
+##
+cat<<EOF
+welcome to SHACK UTTERANCE version 0.9 beta 3
+get help with /help
+TIP: benutze rlwrap für eine elitäre Kommandozeile.
+EOF
+##
+##
+##
+exec >>$linefeed
+##
+##
+##
+echo '/set prompt "READY.~%"'
+echo '/set default_command espeak'
+##
+##
+##
+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..10ae3c1c
--- /dev/null
+++ b/noise-as-shack
@@ -0,0 +1,4 @@
+#! /bin/sh
+qname="`readlink -f "$0"`"
+dirname="`dirname "$qname"`"
+exec su - shack -c "env -i TCPREMOTEIP=\"$TCPREMOTEIP\" \"$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"