View Single Post
  #7   (View Single Post)  
Old 16th April 2019
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,254
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 from US sources rather than interpolated data from Scandinavia.

The following scripts will pull METAR (MEteorological Terminal Area Report) and METAF (MEteorological Terminal Area Forecast) from a nearby U.S. airport. These are free aviation weather products which are updated hourly.
~/scripts/weather.sh
Code:
#!/bin/ksh
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/terminal_forecast.sh
Code:
#!/bin/ksh
# 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 <http://weather.noaa.gov/pub/data/forecasts/zone/> for a list.
#
xterm -g 75x50-1+39 -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
~/scripts/weather_radar.sh
Code:
#!/bin/ksh

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

# The script is configured for the Northwest.
# 
# Animated gifs available at https://www.wunderground.com/weather-radar/united-states/

curl https://icons.wxug.com/data/weather-maps/radar/united-states/redmond-oregon-region-current-radar-animation.gif | \
 animate -immutable -loop 0 -title "NorthWest Radar Loop"
You can adapt this script 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/ksh

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/terminal_forecast.sh' \
--field="PDT Radar":fbtn 'sh /home/YOUR_USER/scripts/pdt_radar.sh' \
--field="NW Satellite":fbtn 'sh /home/YOUR_USER/scripts/noaa_nw_radar.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=gtk-cancel:6
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/Adwaita/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; 5th May 2019 at 08:03 PM.
Reply With Quote