summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xnws30
-rw-r--r--nws.conf3
2 files changed, 25 insertions, 8 deletions
diff --git a/nws b/nws
index 26bd8ed..63c6830 100755
--- a/nws
+++ b/nws
@@ -1,4 +1,6 @@
#!/bin/bash
+# nws - a National Weather Service terminal client
+# git.slickd.xyz/nws
source ~/.config/nws.conf
@@ -9,7 +11,7 @@ colors() {
}
cleanup() {
- rm -rf ~/.cache/.county_ids ~/.cache/.weather_forecast ~/.cache/.weather_alerts
+ rm -rf ~/.cache/.county_ids ~/.cache/.weather_forecast ~/.cache/.weather_alerts /tmp/nws/
}
retrieve_counties() {
@@ -39,10 +41,6 @@ show_full_radar() {
mpv --loop-file=inf "https://radar.weather.gov/ridge/standard/CONUS_loop.gif"
}
-show_timing() {
- mpv --loop-file=inf "https://www.weather.gov/images/${area2}/graphicast/image6.png"
-}
-
show_alerts() {
colors
curl -s "https://api.weather.gov/alerts/active/zone/${countyId}" >> ~/.cache/.weather_alerts
@@ -89,6 +87,22 @@ show_spc() {
mpv --loop-file=inf "https://www.spc.noaa.gov/products/activity_loop.gif"
}
+get_graphicast() {
+ mkdir -p /tmp/nws/
+ count=1
+ prog=12.5
+ bar="#"
+ while [ $count -le 8 ]
+ do
+ wget -q -P /tmp/nws https://www.weather.gov/images/oun/graphicast/image${count}.png
+ echo -ne "${bar} (${prog}%)\r"
+ ((count++))
+ prog=$(echo "$prog + 12.5" | bc)
+ bar="${bar}#"
+ done
+ $IV /tmp/nws/*
+}
+
get_forecast() {
colors
get_location
@@ -120,10 +134,10 @@ help() {
echo " --spc: shows storm predictions"
echo " --retrieve-counties: shows county ids"
echo " --ca: shows number of alerts"
+ echo " --gc: shows graphic forecast, uses image viewer set in config"
echo " -a: shows alerts"
echo " -f: shows local forecast"
}
-
cleanup
case $1 in
"--full-radar") show_full_radar;;
@@ -131,9 +145,9 @@ case $1 in
'--spc') show_spc;;
'--retrieve-counties') retrieve_counties;;
'--ca') count_alerts;;
- '-t') show_timing;;
+ '--gc') get_graphicast;;
'-a') show_alerts | sed 's/null//g ; s/"//g' |less -R;;
- '-f') get_forecast | sed 's/"//g' | less -R;;
+ '-f') get_forecast | sed 's/"//g ; s/null/0/g' | less -R;;
'-h') help;;
"") help;;
esac
diff --git a/nws.conf b/nws.conf
index a3ef2e1..950cbcb 100644
--- a/nws.conf
+++ b/nws.conf
@@ -1,3 +1,6 @@
+# image viewer for graphicast
+IV="nsxiv"
+
# two letter state code
state="OK"