handle missing weather data
This commit is contained in:
parent
93364f4be7
commit
f012b3ea4a
23
dwmstatus.sh
23
dwmstatus.sh
|
@ -4,16 +4,19 @@ while true; do
|
||||||
time=`date +"🕑 %d.%m. %H:%M"`
|
time=`date +"🕑 %d.%m. %H:%M"`
|
||||||
|
|
||||||
weatherdata=`cat weatherdump`
|
weatherdata=`cat weatherdump`
|
||||||
current=`echo "$weatherdata" | jq -r '.current_condition | .[0]'`
|
if [ -z "$weatherdata" ]; then
|
||||||
temp=`echo "$current" | jq -r '.temp_C'`
|
weather="No weather data..."
|
||||||
weatherDesc=`echo "$current" | jq -r '.weatherDesc | .[0].value'`
|
else
|
||||||
wind=`echo "$current" | jq -r '.windspeedKmph'`
|
current=`echo "$weatherdata" | jq -r '.current_condition | .[0]'`
|
||||||
astronomy=`echo "$weatherdata" | jq -r '.weather | .[0] .astronomy | .[0]'`
|
temp=`echo "$current" | jq -r '.temp_C'`
|
||||||
moonphase=`echo "$astronomy" | jq -r '.moon_phase'`
|
weatherDesc=`echo "$current" | jq -r '.weatherDesc | .[0].value'`
|
||||||
sunrise=`echo "$astronomy" | jq -r '.sunrise'`
|
wind=`echo "$current" | jq -r '.windspeedKmph'`
|
||||||
sunset=`echo "$astronomy" | jq -r '.sunset'`
|
astronomy=`echo "$weatherdata" | jq -r '.weather | .[0] .astronomy | .[0]'`
|
||||||
weather="🌡 $temp°C $weatherDesc $wind""km/h Daylight $sunrise-$sunset, Moon $moonphase"
|
moonphase=`echo "$astronomy" | jq -r '.moon_phase'`
|
||||||
|
sunrise=`echo "$astronomy" | jq -r '.sunrise'`
|
||||||
|
sunset=`echo "$astronomy" | jq -r '.sunset'`
|
||||||
|
weather="🌡 $temp°C $weatherDesc $wind""km/h Daylight $sunrise-$sunset, Moon $moonphase"
|
||||||
|
fi
|
||||||
xsetroot -name "$weather $time "
|
xsetroot -name "$weather $time "
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue
Block a user