diff options
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/date | 6 | ||||
-rwxr-xr-x | modules/echo | 6 | ||||
-rwxr-xr-x | modules/espeak | 24 | ||||
-rwxr-xr-x | modules/help | 24 | ||||
-rwxr-xr-x | modules/lang | 22 | ||||
-rwxr-xr-x | modules/play | 32 | ||||
-rwxr-xr-x | modules/sleep | 10 | ||||
-rwxr-xr-x | modules/wall | 8 | ||||
-rwxr-xr-x | modules/zeit | 19 |
9 files changed, 151 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 "[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/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/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 '[31;1mFAIL: $1 is not a number[m' + 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 "[31mError: unsupported [4mlang[0;31m = $lang[m" >&2 + esac + echo /set pitch ${noise_pitch-100} +esac 2>&1 |