summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-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
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 "$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