added rader hook
This commit is contained in:
parent
b8e65a6961
commit
b3380609b7
31
weather
31
weather
@ -16,6 +16,7 @@ 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
|
||||||
-h, --help displays this message
|
-h, --help displays this message
|
||||||
|
|
||||||
ZIPCODE sets the location to the given zipcode
|
ZIPCODE sets the location to the given zipcode
|
||||||
@ -267,6 +268,28 @@ load_info() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
display_radar() {
|
||||||
|
# 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
|
||||||
|
# grabbing nws station
|
||||||
|
NWS=$(curl -fsSL "https://api.weather.gov/points/$LAT,$LON")
|
||||||
|
STATION=$(echo "$NWS" | gojq '.properties.radarStation' | tr -d '"')
|
||||||
|
|
||||||
|
# validation
|
||||||
|
if [[ -z "$STATION" ]] ; then
|
||||||
|
echo "NWS Station error!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# mpv to play weather in fullscreen
|
||||||
|
echo "Fetching weather for NWS Station $STATION..."
|
||||||
|
mpv --fs --loop-file "https://radar.weather.gov/ridge/standard/${STATION}_loop.gif" >/dev/null 2>&1
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
get_icon() {
|
get_icon() {
|
||||||
# sets NF symbols
|
# sets NF symbols
|
||||||
tod=$(echo "$1" | sed --expression='s/[0-9]//g')
|
tod=$(echo "$1" | sed --expression='s/[0-9]//g')
|
||||||
@ -337,6 +360,7 @@ icon_test() {
|
|||||||
printf 'Degrees (F) \ufa04\n'
|
printf 'Degrees (F) \ufa04\n'
|
||||||
printf 'Degrees (C) \ufa03\n'
|
printf 'Degrees (C) \ufa03\n'
|
||||||
printf '%% Humidity \ue373\n'
|
printf '%% Humidity \ue373\n'
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# shifting longform
|
# shifting longform
|
||||||
@ -352,6 +376,7 @@ for arg in "$@"; do
|
|||||||
'--pretty') set -- "$@" "-p" ;;
|
'--pretty') set -- "$@" "-p" ;;
|
||||||
'--pretty') set -- "$@" "-p" ;;
|
'--pretty') set -- "$@" "-p" ;;
|
||||||
'--icon_test') set -- "$@" "-i" ;;
|
'--icon_test') set -- "$@" "-i" ;;
|
||||||
|
'--radar') set -- "$@" "-r" ;;
|
||||||
'--help') set -- "$@" "-h" ;;
|
'--help') set -- "$@" "-h" ;;
|
||||||
*) set -- "$@" "$arg" ;;
|
*) set -- "$@" "$arg" ;;
|
||||||
esac
|
esac
|
||||||
@ -360,7 +385,7 @@ done
|
|||||||
# loading the info
|
# loading the info
|
||||||
load_info
|
load_info
|
||||||
|
|
||||||
while getopts "chpldiz:s:u:a:" opt; do
|
while getopts "chpldriz:s:u:a:" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
'a' )
|
'a' )
|
||||||
API_KEY="$OPTARG"
|
API_KEY="$OPTARG"
|
||||||
@ -387,7 +412,9 @@ while getopts "chpldiz:s:u:a:" opt; do
|
|||||||
;;
|
;;
|
||||||
'i' )
|
'i' )
|
||||||
icon_test
|
icon_test
|
||||||
exit 0
|
;;
|
||||||
|
'r' )
|
||||||
|
display_radar
|
||||||
;;
|
;;
|
||||||
'h' )
|
'h' )
|
||||||
usage 0
|
usage 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user