diff options
author | root <root@krebs> | 2011-04-22 12:29:55 +0200 |
---|---|---|
committer | root <root@krebs> | 2011-04-22 12:29:55 +0200 |
commit | b7fb99573d5075acda4e53ea0e6c62eaa8d015b3 (patch) | |
tree | 0a3f20e7ca552b21c0ac965678dbb532fd537ae3 /modules | |
parent | 0c633c12d5658c963cec93526936666781f4f359 (diff) |
modules/temp: extract temp from /shackstatus
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/temp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/temp b/modules/temp new file mode 100755 index 00000000..047dfa5b --- /dev/null +++ b/modules/temp @@ -0,0 +1,41 @@ +#! /bin/bash + +main() { + case "$1" in + (--help) + echo "report temperature in K, °C, °R, or °F." + ;; + (-C|--celsius) + echo `temp 'x - 273.15'` Grad Zelsius | to_espeak + ;; + (-F|--fahrenheit) + echo `temp 'x * 9/5 - 459.67'` Grad Fahrenheit | to_espeak + ;; + (-R|--rankine) + echo `temp 'x * 9/5'` Grad Renkin | to_espeak + ;; + (-K|--kelvin|*) + echo `temp` Kelvin | to_espeak + ;; + esac +} + +## temp [<formula with temperature as x>] +## Echo temperature in K. If formula is given then return that result instead. +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 +} + +to_espeak() { + sed ' + s/\(\.[0-9]\)0\+/\1/g + s/\(\.[0-9]\)\([0-9]\)[0-9]*/ \1 \2 /; + s/^-/minus /; + s/\./ komma /; + s:^:/espeak -v Die Außen-tempera-tur beträgt :; + ' >$NOISE_linefeed +} + +main "$@" |