diff options
Diffstat (limited to 'nws')
| -rwxr-xr-x | nws | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -2,7 +2,7 @@ # nws - a National Weather Service terminal client # git.slickd.xyz/nws -source ~/.config/nws/nws.conf +source $HOME/.config/nws/nws.conf version=v0.0.4 colors() { @@ -22,12 +22,12 @@ save_json() { exit fi echo -ne "Downloading files... (1 of 3)\r" - curl -s ipinfo.io/json >> ${OUTPUT}/location.json - cords=$(jq -r '.loc' ${OUTPUT}/location.json) + curl -s ipinfo.io>> "${OUTPUT}"/location.json + cords=$(jq -r '.loc' "${OUTPUT}"/location.json) echo -ne "Downloading files... (2 of 3)\r" - curl -s https://api.weather.gov/points/$cords >> ${OUTPUT}/weather.json + curl -s https://api.weather.gov/points/$cords >> "${OUTPUT}"/weather.json echo -ne "Downloading files... (3 of 3)\r" - curl -s https://api.weather.gov/alerts/active/zone/${countyId} >> ${OUTPUT}/alerts.json + curl -s https://api.weather.gov/alerts/active/zone/"${countyId}" >> "${OUTPUT}"/alerts.json echo -e \n\nFinished } @@ -47,10 +47,14 @@ retrieve_counties() { get_location() { - file=$(curl ipinfo.io/json >> /tmp/nws/loc) - cords=$(jq -r '.loc' /tmp/nws/loc) - city=$(jq -r '.city' /tmp/nws/loc) - state=$(jq -r '.region' /tmp/nws/loc) + if [ ! -f ~/.config/nws/location.json ]; then + echo Downloading file + curl ipinfo.io >> ~/.config/nws/location.json + else + cords=$(jq -r '.loc' ~/.config/nws/location.json) + city=$(jq -r '.city' ~/.config/nws/location.json) + state=$(jq -r '.region' ~/.config/nws/location.json) + fi } show_radar() { @@ -168,7 +172,7 @@ help() { echo "Other operations:" echo echo " --retrieve-counties: shows county ids" - echo " --save-json: saves JSON files used to a directory" + echo " --save-json: saves JSON files used to a directory" echo " --ca: shows number of alerts" echo " --gc: shows graphic forecast, uses image viewer set in config" echo |