added rader hook
This commit is contained in:
parent
b3380609b7
commit
b1314bb16a
30
weather
30
weather
@ -16,8 +16,9 @@ options:
|
|||||||
-s, --search returns the weather for QUERY
|
-s, --search returns the weather for QUERY
|
||||||
-u, --units sets the temperature units
|
-u, --units sets the temperature units
|
||||||
-i, --icon_test tests the icons used
|
-i, --icon_test tests the icons used
|
||||||
-r, --radar requests the radar for a given location
|
-r, --radar displays the radar for a given location
|
||||||
-h, --help displays this message
|
-f, --forecast displays the forecast a given location
|
||||||
|
-h, --help show this message
|
||||||
|
|
||||||
ZIPCODE sets the location to the given zipcode
|
ZIPCODE sets the location to the given zipcode
|
||||||
to narrow results, include the ISO country code
|
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() {
|
display_radar() {
|
||||||
# two step process, gets weather station from NWS, then mpv to play radar
|
# two step process, gets weather station from NWS, then mpv to play radar
|
||||||
if [[ -z "$LAT" || -z "$LON" ]] ; then
|
if [[ -z "$LAT" || -z "$LON" ]] ; then
|
||||||
@ -377,6 +397,7 @@ for arg in "$@"; do
|
|||||||
'--pretty') set -- "$@" "-p" ;;
|
'--pretty') set -- "$@" "-p" ;;
|
||||||
'--icon_test') set -- "$@" "-i" ;;
|
'--icon_test') set -- "$@" "-i" ;;
|
||||||
'--radar') set -- "$@" "-r" ;;
|
'--radar') set -- "$@" "-r" ;;
|
||||||
|
'--forecast') set -- "$@" "-f" ;;
|
||||||
'--help') set -- "$@" "-h" ;;
|
'--help') set -- "$@" "-h" ;;
|
||||||
*) set -- "$@" "$arg" ;;
|
*) set -- "$@" "$arg" ;;
|
||||||
esac
|
esac
|
||||||
@ -385,7 +406,7 @@ done
|
|||||||
# loading the info
|
# loading the info
|
||||||
load_info
|
load_info
|
||||||
|
|
||||||
while getopts "chpldriz:s:u:a:" opt; do
|
while getopts "chpldrfiz:s:u:a:" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
'a' )
|
'a' )
|
||||||
API_KEY="$OPTARG"
|
API_KEY="$OPTARG"
|
||||||
@ -416,6 +437,9 @@ while getopts "chpldriz:s:u:a:" opt; do
|
|||||||
'r' )
|
'r' )
|
||||||
display_radar
|
display_radar
|
||||||
;;
|
;;
|
||||||
|
'f' )
|
||||||
|
display_forecast
|
||||||
|
;;
|
||||||
'h' )
|
'h' )
|
||||||
usage 0
|
usage 0
|
||||||
;;
|
;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user