diff --git a/weather b/weather index 1df4a64..763584c 100755 --- a/weather +++ b/weather @@ -16,8 +16,9 @@ options: -s, --search returns the weather for QUERY -u, --units sets the temperature units -i, --icon_test tests the icons used - -r, --radar requests the radar for a given location - -h, --help displays this message + -r, --radar displays the radar for a given location + -f, --forecast displays the forecast a given location + -h, --help show this message ZIPCODE sets the location to the given zipcode to narrow results, include the ISO country code @@ -268,6 +269,25 @@ load_info() { } +display_forecast() { + # two step process, gets weather station from NWS, then mpv to play radar + if [[ -z "$LAT" || -z "$LON" ]] ; then + echo "Location not found!" + exit 1 + fi + + FORECAST="curl -fsSL https://wttr.in/${LAT},${LON}" + + if [[ ! -z "$TMUX" ]] ; then + # can display in a popup + tmux display-popup "echo 'Grabbing forecast...'; $FORECAST" + else + setsid -f $FORECAST + fi + + exit 0 +} + display_radar() { # two step process, gets weather station from NWS, then mpv to play radar if [[ -z "$LAT" || -z "$LON" ]] ; then @@ -377,6 +397,7 @@ for arg in "$@"; do '--pretty') set -- "$@" "-p" ;; '--icon_test') set -- "$@" "-i" ;; '--radar') set -- "$@" "-r" ;; + '--forecast') set -- "$@" "-f" ;; '--help') set -- "$@" "-h" ;; *) set -- "$@" "$arg" ;; esac @@ -385,7 +406,7 @@ done # loading the info load_info -while getopts "chpldriz:s:u:a:" opt; do +while getopts "chpldrfiz:s:u:a:" opt; do case "$opt" in 'a' ) API_KEY="$OPTARG" @@ -416,6 +437,9 @@ while getopts "chpldriz:s:u:a:" opt; do 'r' ) display_radar ;; + 'f' ) + display_forecast + ;; 'h' ) usage 0 ;;