homeserver/friedhof/mgrote_motd/templates/10-wetter-mgrote

41 lines
1.5 KiB
Text
Raw Permalink Normal View History

2020-08-18 11:57:53 +02:00
#!/bin/bash
{{ file_header | default () }}
2020-08-18 11:57:53 +02:00
# NAME: now
# PATH: $HOME/bin
# DESC: Display current weather, calendar and time
# CALL: Called from terminal or ~/.bashrc
# DATE: Apr 6, 2017. Modified: May 24, 2019.
# UPDT: 2019-05-24 If Weather unavailable nicely formatted error message.
# NOTE: To display all available toilet fonts use this one-liner:
# for i in ${TOILET_FONT_PATH:=/usr/share/figlet}/*.{t,f}lf; do j=${i##*/}; toilet -d "${i%/*}" -f "$j" "${j%.*}"; done
# Setup for 92 character wide terminal
DateColumn=34 # Default is 27 for 80 character line, 34 for 92 character line
TimeColumn=61 # Default is 49 for " " " " 61 " " " "
# Replace Edmonton with your city name, GPS, etc. See: curl wttr.in/:help
curl wttr.in/{{ motd_wetter_ort }}?0 --silent --max-time 10 > /tmp/now-weather
# Timeout #. Increase for slow connection---^
readarray aWeather < /tmp/now-weather
rm -f /tmp/now-weather
# Was valid weather report found or an error message?
if [[ "${aWeather[0]}" == "Weather report:"* ]] ; then
WeatherSuccess=true
echo "${aWeather[@]}"
else
WeatherSuccess=false
echo "+============================+"
echo "| Weather unavailable now!!! |"
echo "| Check reason with command: |"
echo "| |"
echo "| curl wttr.in/Edmonton?0 |" # Replace Edmonton with your city
echo "| --silent --max-time 10 |"
echo "+============================+"
echo " "
fi
echo " " # Pad blank lines for calendar & time to fit