diff options
author | Vidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com> | 2020-12-01 12:10:20 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com> | 2020-12-01 12:10:20 +0530 |
commit | c0333b8bd91b164d452e515fb4176089823aa65a (patch) | |
tree | 6f0069a19943daf1bd95f90589b457eb1883e599 /scripts | |
parent | 6c055d89bdfd51eab7ba111a95dd55701d1c9888 (diff) |
fixed the temperature being blank if weather stat wasn't haze; currently only supports haze and smoke
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/weather | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/scripts/weather b/scripts/weather index 3fcab925..cc0ac150 100755 --- a/scripts/weather +++ b/scripts/weather @@ -1,12 +1,21 @@ #!/bin/bash get_current_temp() { - temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $9 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g") # > /tmp/weather_temperature) - stat=$(curl wttr.in | awk 'NR==3 {print $1}') - echo $temp "("$stat")" + if [ $stat == "Smoke" ]; then + temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $4 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g") + elif [ $stat == "Haze" ]; then + temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $9 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g") + fi + + echo $temp +} + +get_current_weather() { + stat=$(curl wttr.in | awk 'NR==3 {print $1}') + echo $(get_current_temp) "("$stat")" } while :; do - echo $(get_current_temp) > /tmp/weather_stat + echo $(get_current_weather) > /tmp/weather_stat sleep 3600 done |