Get the location based on the ip from freegeoip

If LOCATION is not set get the location based on the ip from freegeoip
This commit is contained in:
M.Zeinali 2021-09-16 23:56:20 +04:30 committed by GitHub
parent f1814b3690
commit a438e92778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@
# You could set up a shell alias to view the full file in a pager in the
# terminal if desired. This function will only be run once a day when needed.
weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport"
[ -z "$LOCATION" ] && LOCATION="$(curl -s https://freegeoip.app/json/ | jq .city)"
getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;}
# Some very particular and terse stream manipulation. We get the maximum