A desktop notifier for new runs
Weather models publish on a schedule. This little daemon polls your slices, watches each one's last_run_time, and fires a native desktop notification when a
fresh run lands — so you know to re-download.
The script
It polls /v1/slices every 10 minutes, remembers the run it last announced per
slice, and notifies via osascript on macOS or notify-send on Linux. The
first pass just primes the state (no spurious alerts on startup).
#!/usr/bin/env python3
"""Pop a desktop notification when any of your slices gets a new model run."""
import os, sys, time, subprocess, requests
S = requests.Session()
S.headers["Authorization"] = f"Bearer {os.environ['WF_TOKEN']}"
URL = "https://api.weatherfiles.com/v1/slices"
POLL_SECONDS = 600
def notify(title, msg):
if sys.platform == "darwin":
subprocess.run(["osascript", "-e",
f'display notification "{msg}" with title "{title}"'])
else: # Linux / BSD with libnotify
subprocess.run(["notify-send", title, msg])
seen = {} # token -> last_run_time we've already announced
while True:
try:
for sl in S.get(URL, timeout=30).json():
tok, run = sl["token"], sl["last_run_time"]
name = sl["label"] or sl["model_id"]
if tok in seen and run and run != seen[tok]:
notify("WeatherFiles", f"New run for {name}: {run}")
seen[tok] = run # first pass primes; later changes notify
except requests.RequestException:
pass # transient - try again next poll
time.sleep(POLL_SECONDS) Run it
- Linux: ensure
libnotify(notify-send) is installed; run it from your session, or as a user systemd service. - macOS: no dependency —
osascriptis built in. - Polling every 10 minutes is gentle on the API; tighten only if you need to.
Want to act on the notification automatically? Swap notify() for a call into the slice client's download() to fetch the new run
on the spot.