diff options
author | makefu <github@syntax-fehler.de> | 2011-09-12 14:32:18 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2011-09-12 14:32:18 +0200 |
commit | 9f70f9b5b462aa3e150b9708f695edfaf716edd4 (patch) | |
tree | 5cbebe6cbc0ada2c988d7f14d0bbbc52a68b37c1 /noise | |
parent | 568fbd7fa5541182bbbc33560863ec9c3ff01d48 (diff) | |
parent | a07326f6c57a7e8f49b9bef96ded427275a16e2e (diff) |
Merge branch 'master' into punani_files
Diffstat (limited to 'noise')
-rwxr-xr-x | noise/modules/ein_mal_eins | 2 | ||||
-rwxr-xr-x | noise/modules/help | 6 | ||||
-rwxr-xr-x | noise/modules/mpc | 2 | ||||
-rwxr-xr-x | noise/modules/overlord | 14 | ||||
-rwxr-xr-x | noise/modules/play | 6 | ||||
-rwxr-xr-x | noise/modules/temp | 42 | ||||
-rwxr-xr-x | noise/noise | 26 |
7 files changed, 55 insertions, 43 deletions
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 } 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/$/[m/ - s:^([a-z]+) (.+):[35mtype [32m/\1[35m to \2:p' ;; + s:^\([a-z]\+\) \(.\+\):[35mtype [32m/\1[35m to \2:p' ;; (*) ## call for directory in `echo "$NOISE_PATH" | tr : \ ` ; do 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 diff --git a/noise/modules/overlord b/noise/modules/overlord new file mode 100755 index 00000000..ded8627a --- /dev/null +++ b/noise/modules/overlord @@ -0,0 +1,14 @@ +#! /bin/sh +set -euf + +# cd // +cd $(dirname $(readlink -f $0))/../.. + +case "${1---help}" in + --help) + echo "Make an announcement! Usage: /overlord <text>" + ;; + *) + exec god/overlord/index "$@" + ;; +esac 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 \ \|`"')$: [30m\1[m: + ls $HOME/noise/samples | sed ' + s:\.\('"`echo "$ffs" | tr \ \|`"'\)$: [30m\1[m: s:^:/play : s:.*:[32m&[m: ' @@ -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[m EOF diff --git a/noise/modules/temp b/noise/modules/temp index 2f1dfcef..a11c3720 100755 --- a/noise/modules/temp +++ b/noise/modules/temp @@ -1,33 +1,32 @@ #! /bin/bash +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) - espeak_inside `inside_temp 'x - 273.15'` Grad Zelsius - espeak_outside `outside_temp 'x - 273.15'` Grad Zelsius - ;; - (-F|--fahrenheit) - espeak_inside `inside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit - espeak_outside `outside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit - ;; - (-R|--rankine) - espeak_inside `inside_temp 'x * 9/5'` Grad Renkin - espeak_outside `outside_temp 'x * 9/5'` Grad Renkin - ;; - (-K|--kelvin|*) - espeak_inside `inside_temp` Kelvin - espeak_outside `outside_temp` Kelvin + (-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 + espeak_inside `inside_temp "$formula"` $unit + fi + espeak_outside `outside_temp "$formula"` $unit } ## temp [<formula with temperature as x>] ## 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() { @@ -36,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 ' diff --git a/noise/noise b/noise/noise index bd6b17c8..615277a6 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:]_]+)=(.*)$/[35;4m\1[;35m = [32m\2[m/p + env | sed -n ' + s/^noise_\([[:alnum:]_]\+\)=\(.*\)$/[35;4m\1[;35m = [32m\2[m/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 + cache="`cat $env`" + echo "$cache" | + sed "s'^\($1\)=\(.*\)\$'\1=\'$2\''" > $env else echo "$1='$2'" >>$env fi @@ -47,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: $@" @@ -90,13 +94,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 +141,8 @@ commit ` [m [33;1mJoin 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/ |