mg
8dcd648f0b
header eingebaut Co-authored-by: Michael Grote <michael.grote@posteo.de> Reviewed-on: mg/ansible#149 Co-Authored-By: mg <mg@noreply.git.mgrote.net> Co-Committed-By: mg <mg@noreply.git.mgrote.net>
40 lines
1.5 KiB
Bash
40 lines
1.5 KiB
Bash
#!/bin/bash
|
|
{{ file_header | default () }}
|
|
# 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
|