blob: 047dfa5b8d90bcfbe1726c3dde900baa4219c63c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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 "$@"
|