View Single Post
  #6   (View Single Post)  
Old 18th October 2019
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,507
Default

Time and Weather

NTP, x11/yad, graphics/ImageMagick and net/curl based Weather scripts. Note: In OpenBSD, it is possible to use the base ftp command to pull the *.txt files from https:// sites. I used curl so the same scripts will run in Debian as #!/bin/bash scripts. If you are an OpenBSD purist, you can easily modify the scripts to use the base ftp command.

The base distribution utilizes openntpd to synch the computer clock on startup. man ntpd.

My father was a USN trained pilot/navigator who compulsively sync'd his watch to the National Institute of Standards and closely monitored the weather. These weather scripts are helpful in scheduling outdoor activities and IMHO are better than the Gnome/XFCE4/KDE weather applications for US users. They do not constantly poll saving CPU cycles and bandwidth. The data is direct from US sources rather than extrapolated data from https://www.met.no.

The following scripts will pull METAR (MEteorological Terminal Area Report) and METAF (MEteorological Terminal Area Forecast) from a nearby U.S. airport (ICAO code). These are free aviation weather products which are updated hourly. These can also serve as examples for pulling *.txt files and animated gif's. You should be able to paste in the url for your local product(s).
~/Scripts/weather.sh
Code:
#!/bin/sh
xterm -g 75x17-1+39 -T "Yakima, WA Weather" -hold -e \
curl -sk https://tgftp.nws.noaa.gov/data/observations/metar/decoded/KYKM.TXT
~/Scripts/weather_forecast.sh
Code:
#!/bin/sh
# This is a simple script that downloads current weather conditions and zone
# forecast from the National Weather Service to /tmp and displays them.
# 
# To change the forecast zone, replace wa/waz027 with another forecast zone.
# See <https://weather.noaa.gov/pub/data/forecasts/zone/> for a list.
#
xterm -g 75x50-1+38 -T "Yakima, WA Forecast" -hold -e \
curl -sk https://tgftp.nws.noaa.gov/data/forecasts/zone/wa/waz027.txt
This script pulls an animated *gif of a nearby weather radar station and displays it in ImageMagick
In the US you can browse the available images at:
https://radar.weather.gov/ridge/standard/.
If you know the ICAO code for your nearby airport, you should see it in the list
https://en.wikipedia.org/wiki/ICAO_airport_code
~/Scripts/weather_radar.sh
Code:
#!/bin/sh

# This is a simple script that downloads a composite radar image for the NW from
# the National Weather Service

# The script is configured for the Pacific Northwest.
# 
# You can browse "https://radar.weather.gov/ridge/standard/" for your area

curl https://radar.weather.gov/ridge/standard/PACNORTHWEST_loop.gif  | \
 animate -immutable -loop 0 -title "NorthWest Radar Loop"
This script can be adapted to pull any Weather Wunderground animated gif, NOAA satellite gif's and weather.gov radar 'loop' images you can find on the internet.

I use a yad --form to group all my weather products
~/Scripts/yad_weather.sh
Code:
#!/bin/sh

GTK_THEME=Adwaita:dark \
yad --form --width=256 --text="Weather Menu:" --title="Weather" \
--field="KYKM Current":fbtn 'sh /home/YOUR_USER/scripts/weather.sh' \
--field="KYKM Forecast":fbtn 'sh /home/YOUR_USER/scripts/weather_forecast.sh' \
--field="KYKM TAF":fbtn 'sh /home/YOUR_USER/scripts/kykm_taf.sh' \
--field="PDT Radar":fbtn 'sh /home/YOUR_USER/scripts/pdt_radar.sh' \
--field="NW Satellite":fbtn 'sh /home/YOUR_USER/scripts/nw_satellite.sh' \
--field="NW Composite Radar":fbtn 'sh /home/YOUR_USER/scripts/weather_radar.sh' \
--field="CONUS Radar":fbtn 'sh /home/YOUR_USER/scripts/conus_radar.sh' \
--window-icon=weather-overcast --button=Close6
You can add/delete --field lines as needed.

and call the yad_weather.sh script with a tint2 button
~/.config/tint2/tint2rc
Code:
#-------------------------------------
# Button 1
button = new
button_icon = /usr/local/share/icons/Paper/32x32/status/weather-overcast.png
button_text = 
button_tooltip = "Yakima, WA Weather"
button_lclick_command = ~/Scripts/yad_weather.sh
button_rclick_command = ~/Scripts/yad_weather.sh
button_mclick_command = 
button_uwheel_command = 
button_dwheel_command = 
button_font_color = #000000 100
button_padding = 6 3
button_background_id = 0
button_centered = 0
button_max_icon_size = 32

#-------------------------------------
This code is in the provided ~/.config/tint2/tint2rc and can be enabled by editing
Code:
#-------------------------------------
# Panel
panel_items = TSC
panel_size = 100% 38
to

Code:
#-------------------------------------
# Panel
panel_items = TSPC
panel_size = 100% 38

Last edited by shep; 16th May 2023 at 11:23 PM. Reason: updated for yad New weather.gov radar server
Reply With Quote