From 9f4fae0616d76735790045465fd3994353af8f32 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 15:34:39 +0200 Subject: //noise/modules/ein_mal_eins: use BRE @sed --- noise/modules/ein_mal_eins | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'noise') diff --git a/noise/modules/ein_mal_eins b/noise/modules/ein_mal_eins index fb385b31..e21612a5 100755 --- a/noise/modules/ein_mal_eins +++ b/noise/modules/ein_mal_eins @@ -1,7 +1,7 @@ #! /bin/bash R() { - echo "`od -t d -N 1 /dev/urandom | sed -rn '1s/^[0-9]+ +//p'` % $@" | bc + echo "`od -t d -N 1 /dev/urandom | sed -n '1s/^[0-9]\+ \+//p'` % $@" | bc } -- cgit v1.2.3 From 6a0a39ab43ee2754c8919328aea53b9597621667 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 15:37:29 +0200 Subject: //noise/modules/help: use BRE @sed --- noise/modules/help | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'noise') diff --git a/noise/modules/help b/noise/modules/help index bc4c2931..0763f3a0 100755 --- a/noise/modules/help +++ b/noise/modules/help @@ -7,10 +7,10 @@ case "$1" in done 2>/dev/null done ## print all documented built-in commands - sed -rn 's:^noise_([a-z]+)\(\) \{ # (.+)?$:\1 \2:p' "$NOISE" - } | sort | uniq | sed -rn ' + sed -n 's:^noise_\([a-z]\+\)() { # \(.\+\)\?$:\1 \2:p' "$NOISE" + } | sort | uniq | sed -n ' $s/$// - s:^([a-z]+) (.+):type /\1 to \2:p' ;; + s:^\([a-z]\+\) \(.\+\):type /\1 to \2:p' ;; (*) ## call for directory in `echo "$NOISE_PATH" | tr : \ ` ; do -- cgit v1.2.3 From c6d5e62104ed4ab76cc8d90979fa7a64f67c8c47 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 15:42:06 +0200 Subject: //noise/modules/play: use BRE @sed --- noise/modules/play | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'noise') diff --git a/noise/modules/play b/noise/modules/play index 749b450a..180c1e0c 100755 --- a/noise/modules/play +++ b/noise/modules/play @@ -7,8 +7,8 @@ case "$1" in ffs='wav mp3 ogg asf flac' if test -z "$*" ; then - ls $HOME/noise/samples | sed -r ' - s:\.('"`echo "$ffs" | tr \ \|`"')$: \1: + ls $HOME/noise/samples | sed ' + s:\.\('"`echo "$ffs" | tr \ \|`"'\)$: \1: s:^:/play : s:.*:&: ' @@ -28,7 +28,7 @@ Keine Audiodatei mit dem Namen gefunden... am besten gleich uploaden: - scp NAME shack@shack.shack:noise/samples/ + scp NAME shack@shack.shack:$HOME/noise/samples/ folgende Dateiendungen werden erkannt: $ffs EOF -- cgit v1.2.3 From 630c7d80d48d0ebfe30c2a84d8b887e6b029bc83 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 15:52:40 +0200 Subject: //noise: use BRE @sed --- noise/noise | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'noise') diff --git a/noise/noise b/noise/noise index bd6b17c8..99a08023 100755 --- a/noise/noise +++ b/noise/noise @@ -7,8 +7,8 @@ noise_set() { # set a variable esac case $# in (0) ## print all noise variables - env | sed -rn ' - s/^noise_([[:alnum:]_]+)=(.*)$/\1 = \2/p + env | sed -n ' + s/^noise_\([[:alnum:]_]\+\)=\(.*\)$/\1 = \2/p ' | sort ;; (1) ## print value the specified variable @@ -31,7 +31,9 @@ noise_set() { # set a variable fi ## write variable to $env if grep -q "^$1=" "$env" ; then - sed -ri "s'^($1)=(.*)\$'\1=\'$2\''" $env + env_cache="`cat $env`" + echo "$env_cache" | + sed "s'^\($1\)=\(.*\)\$'\1=\'$2\''" > $env else echo "$1='$2'" >>$env fi @@ -90,13 +92,13 @@ touch $env ## ## readline() { - { read REPLY && echo "$REPLY" ; } | sed -rn " + { read REPLY && echo "$REPLY" ; } | sed -n " s/[']//g s/~%/\n/g - s/([^\\])([#<>])/\1\\\\\2/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/\([^\\]\)\([#<>]\)/\1\\\\\2/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 " } @@ -137,8 +139,8 @@ commit `  Join the 23.shack-dev-team, we've got ` sloccount $dirname/* | - sed -rn ' - s/.*\(SLOC\)[[:space:]]*=[[:space:]]*([0-9]+)$/\1/p + sed -n ' + s/.*(SLOC)[[:space:]]*=[[:space:]]*\([0-9]\+\)$/\1/p '` SLOC, ` { ls $dirname/modules/ -- cgit v1.2.3 From 150ce5757d2982da740bd9ce2b44b57b6d2831c6 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 18:22:01 +0200 Subject: //noise: kill another instance of sed -i --- noise/noise | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'noise') diff --git a/noise/noise b/noise/noise index 99a08023..615277a6 100755 --- a/noise/noise +++ b/noise/noise @@ -31,8 +31,8 @@ noise_set() { # set a variable fi ## write variable to $env if grep -q "^$1=" "$env" ; then - env_cache="`cat $env`" - echo "$env_cache" | + cache="`cat $env`" + echo "$cache" | sed "s'^\($1\)=\(.*\)\$'\1=\'$2\''" > $env else echo "$1='$2'" >>$env @@ -49,7 +49,9 @@ noise_unset() { # unset a variable case $# in (1) ## unset "noise_$1" - sed -ni "/^$1=/!p" $env + cache="`cat $env`" + echo "$cache" | + sed -n "/^$1=/!p" > $env ;; (*) fail "broken commandline: $@" -- cgit v1.2.3 From 0e49743f32b550e4aa47a899d17f481eaed4fbc8 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Sep 2011 19:34:20 +0200 Subject: //noise/modules/overlord: initial commit --- noise/modules/overlord | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 noise/modules/overlord (limited to 'noise') diff --git a/noise/modules/overlord b/noise/modules/overlord new file mode 100755 index 00000000..6df2451d --- /dev/null +++ b/noise/modules/overlord @@ -0,0 +1,26 @@ +#! /bin/sh +set -euf + +announce() { +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 90% +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 80% +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 70% +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 60% +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 50% +/krebs/streams/streams stop +amixer -q -c 0 -D hw:0 sset Front 100% +mplayer /krebs/god/overlord/announce.mp3 +/krebs/streams/streams start & +espeak -v de -s 120 -a 900 "$*" +amixer -q -c 0 -D hw:0 sset Front 40% +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 50% +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 60% +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 70% +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 80% +sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 90% +} + +case "$1" in + --help) echo "Make an announcement! Usage: /overlord ";; + *) announce "$@";; +esac -- cgit v1.2.3 From a6090c2b84798367ee88c35847ec9194e1ad8842 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Sep 2011 19:44:50 +0200 Subject: //noise /mpc: {mpd -> filebitch}.mpd --- noise/modules/mpc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'noise') diff --git a/noise/modules/mpc b/noise/modules/mpc index 0ab72058..20abf19b 100755 --- a/noise/modules/mpc +++ b/noise/modules/mpc @@ -10,5 +10,5 @@ case "$1" in ##echo test-module called with following arguments: "$@" ## send command for re-evaluation: ##echo /espeak test >$NOISE_linefeed - MPD_HOST=mpd.shack mpc $@ + MPD_HOST=filebitch.shack mpc $@ esac -- cgit v1.2.3 From e71fd36593eebd402dd2aa2425473827dda1c9f2 Mon Sep 17 00:00:00 2001 From: krebs Date: Fri, 9 Sep 2011 20:06:13 -0400 Subject: //noise /overlord: little fixture --- noise/modules/overlord | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'noise') diff --git a/noise/modules/overlord b/noise/modules/overlord index 6df2451d..6edb0fd8 100755 --- a/noise/modules/overlord +++ b/noise/modules/overlord @@ -2,22 +2,31 @@ set -euf announce() { -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 90% -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 80% -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 70% -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 60% -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 50% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 90% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 80% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 70% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 60% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 50% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 40% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 30% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 20% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 10% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 0% /krebs/streams/streams stop amixer -q -c 0 -D hw:0 sset Front 100% mplayer /krebs/god/overlord/announce.mp3 -/krebs/streams/streams start & espeak -v de -s 120 -a 900 "$*" -amixer -q -c 0 -D hw:0 sset Front 40% -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 50% -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 60% -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 70% -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 80% -sleep 0.4; amixer -q -c 0 -D hw:0 sset Front 90% +/krebs/streams/streams start +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 0% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 10% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 20% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 30% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 40% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 50% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 60% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 70% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 80% +sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 90% } case "$1" in -- cgit v1.2.3 From 3b48e005f95dbadcef714e225b3b104b3935e9c7 Mon Sep 17 00:00:00 2001 From: krebs Date: Fri, 9 Sep 2011 20:26:03 -0400 Subject: //noise /overlord: removed redundancy --- noise/modules/overlord | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'noise') diff --git a/noise/modules/overlord b/noise/modules/overlord index 6edb0fd8..53766116 100755 --- a/noise/modules/overlord +++ b/noise/modules/overlord @@ -1,35 +1,31 @@ #! /bin/sh set -euf +max=100 +step=10 +min=0 + announce() { -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 90% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 80% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 70% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 60% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 50% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 40% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 30% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 20% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 10% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 0% -/krebs/streams/streams stop -amixer -q -c 0 -D hw:0 sset Front 100% -mplayer /krebs/god/overlord/announce.mp3 -espeak -v de -s 120 -a 900 "$*" -/krebs/streams/streams start -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 0% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 10% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 20% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 30% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 40% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 50% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 60% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 70% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 80% -sleep 0.1; amixer -q -c 0 -D hw:0 sset Front 90% + # fade-out streams + for i in `seq $max -$step $min`; do + amixer -q -c 0 -D hw:0 sset Front $i% + sleep 0.1 + done + /krebs/streams/streams stop + + amixer -q -c 0 -D hw:0 sset Front $max% + mplayer /krebs/god/overlord/announce.mp3 >/dev/null + espeak -v de -s 120 -a 900 "$*" + + # fade-in streams + /krebs/streams/streams start + for i in `seq $min $step $max`; do + sleep 0.1 + amixer -q -c 0 -D hw:0 sset Front $i% + done } -case "$1" in +case "${1---help}" in --help) echo "Make an announcement! Usage: /overlord ";; *) announce "$@";; esac -- cgit v1.2.3 From 27a38dd34af2e035eb0d37ce2f27f169763c3538 Mon Sep 17 00:00:00 2001 From: krebs Date: Fri, 9 Sep 2011 20:35:04 -0400 Subject: //noise /temp: fix inside-temperature bug --- noise/modules/temp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'noise') diff --git a/noise/modules/temp b/noise/modules/temp index 2f1dfcef..3c364acd 100755 --- a/noise/modules/temp +++ b/noise/modules/temp @@ -1,33 +1,40 @@ #! /bin/bash +temper=/krebs/temper/temper + main() { case "$1" in (--help) echo "report temperature in K, °C, °R, or °F." + exit ;; (-C|--celsius) - espeak_inside `inside_temp 'x - 273.15'` Grad Zelsius - espeak_outside `outside_temp 'x - 273.15'` Grad Zelsius + unit='Grad Zelsius' + formula='x - 273.15' ;; (-F|--fahrenheit) - espeak_inside `inside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit - espeak_outside `outside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit + unit='Grad Fahrenheit' + formula='x * 9/5 - 459.67' ;; (-R|--rankine) - espeak_inside `inside_temp 'x * 9/5'` Grad Renkin - espeak_outside `outside_temp 'x * 9/5'` Grad Renkin + unit='Grad Renkin' + formula='x * 9/5' ;; (-K|--kelvin|*) - espeak_inside `inside_temp` Kelvin - espeak_outside `outside_temp` Kelvin + unit='Kelvin' + formula=x ;; esac + if test -f $temper -a -x $temper; then + espeak_inside `inside_temp "$formula"` $unit + fi + espeak_outside `outside_temp "$formula"` $unit } ## temp [] ## Echo temperature in K. If formula is given then return that result instead. inside_temp() { - echo "scale=2; x=`/krebs/temper/temper` + 273.15; ${1-x}" | bc + echo "scale=2; x=`$temper` + 273.15; ${1-x}" | bc } outside_temp() { -- cgit v1.2.3 From 8712dfa17f0dd7b90c646e13d2cd4e0d4c5a11e6 Mon Sep 17 00:00:00 2001 From: krebs Date: Fri, 9 Sep 2011 21:26:15 -0400 Subject: //god/overlord: be the right and only one This commit also makes the //noise module a pure wrapper around the read overlord. --- noise/modules/overlord | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'noise') diff --git a/noise/modules/overlord b/noise/modules/overlord index 53766116..ded8627a 100755 --- a/noise/modules/overlord +++ b/noise/modules/overlord @@ -1,31 +1,14 @@ #! /bin/sh set -euf -max=100 -step=10 -min=0 - -announce() { - # fade-out streams - for i in `seq $max -$step $min`; do - amixer -q -c 0 -D hw:0 sset Front $i% - sleep 0.1 - done - /krebs/streams/streams stop - - amixer -q -c 0 -D hw:0 sset Front $max% - mplayer /krebs/god/overlord/announce.mp3 >/dev/null - espeak -v de -s 120 -a 900 "$*" - - # fade-in streams - /krebs/streams/streams start - for i in `seq $min $step $max`; do - sleep 0.1 - amixer -q -c 0 -D hw:0 sset Front $i% - done -} +# cd // +cd $(dirname $(readlink -f $0))/../.. case "${1---help}" in - --help) echo "Make an announcement! Usage: /overlord ";; - *) announce "$@";; + --help) + echo "Make an announcement! Usage: /overlord " + ;; + *) + exec god/overlord/index "$@" + ;; esac -- cgit v1.2.3 From 9c9e9809e61e5e6a45c5f5babd0fef17cdc1d33d Mon Sep 17 00:00:00 2001 From: krebs Date: Fri, 9 Sep 2011 21:29:15 -0400 Subject: //noise /temp: compress space --- noise/modules/temp | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'noise') diff --git a/noise/modules/temp b/noise/modules/temp index 3c364acd..a11c3720 100755 --- a/noise/modules/temp +++ b/noise/modules/temp @@ -3,26 +3,18 @@ temper=/krebs/temper/temper main() { - case "$1" in + case "${1--K}" in (--help) echo "report temperature in K, °C, °R, or °F." exit ;; - (-C|--celsius) - unit='Grad Zelsius' - formula='x - 273.15' - ;; - (-F|--fahrenheit) - unit='Grad Fahrenheit' - formula='x * 9/5 - 459.67' - ;; - (-R|--rankine) - unit='Grad Renkin' - formula='x * 9/5' - ;; - (-K|--kelvin|*) - unit='Kelvin' - formula=x + (-C|--celsius) unit='Grad Zelsius' ; formula='x - 273.15' ;; + (-F|--fahrenheit) unit='Grad Fahrenheit'; formula='x * 9/5 - 459.67' ;; + (-R|--rankine) unit='Grad Renkin' ; formula='x * 9/5' ;; + (-K|--kelvin) unit='Kelvin' ; formula='x' ;; + (*) + echo 'Error 1: you are made of stupid!' + exit 23 ;; esac if test -f $temper -a -x $temper; then @@ -43,13 +35,8 @@ outside_temp() { ` + 273.15; ${1-x}" | bc } -espeak_inside() { - echo Die Krebs-tempera-tur beträgt $@ | to_espeak -} - -espeak_outside() { - echo Die Außen-tempera-tur beträgt $@ | to_espeak -} +espeak_inside() { echo Die Krebs-tempera-tur beträgt $@ | to_espeak; } +espeak_outside() { echo Die Außen-tempera-tur beträgt $@ | to_espeak; } to_espeak() { sed ' -- cgit v1.2.3