diff options
author | Felix Richter <Felix.Richter@syntax-fehler.de> | 2011-05-29 15:48:47 +0200 |
---|---|---|
committer | Felix Richter <Felix.Richter@syntax-fehler.de> | 2011-05-29 15:48:47 +0200 |
commit | 30b44417f91eb100fa67a38e9c1c1f88682c92ef (patch) | |
tree | f0c6c97d76c9ac7cfe2c88bdffcaee53ff0bc3ae /noise/modules/temp | |
parent | 427bdf4e2093217f967384f785e3907930a74a21 (diff) | |
parent | 12c77cdbfa4ec48d935af3ae7cf1118e38bec6e1 (diff) |
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'noise/modules/temp')
-rwxr-xr-x | noise/modules/temp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/noise/modules/temp b/noise/modules/temp new file mode 100755 index 00000000..2f1dfcef --- /dev/null +++ b/noise/modules/temp @@ -0,0 +1,56 @@ +#! /bin/bash + +main() { + case "$1" in + (--help) + echo "report temperature in K, °C, °R, or °F." + ;; + (-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 + ;; + esac +} + +## 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 +} + +outside_temp() { + echo "scale=2; x=`dig +short txt outside.elwood.temp.citecs.de | + sed 's/^"DEG \([0-9]\+\.[0-9]\+\)"$/\1/' + ` + 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 +} + +to_espeak() { + sed ' + s/\(\.[0-9]\)0\+/\1/g + s/\(\.[0-9]\)\([0-9]\)[0-9]*/ \1 \2 /; + s/^-/minus /; + s/\./ komma /; + ' | tee $NOISE_linefeed +} + +main "$@" |