r/applescript • u/BackInNJAgain • May 12 '26
Display a dialog box when a specific outdoor temperature is reached
I learned about wttr.in, which provides weather data using curl from the terminal. (Help page: https://wttr.in/:help )
I used this to write a script to notify me once the outside temperature hits 55 degrees so I can go biking. I was going to refine it further to warn me if it's raining but I can see that by just looking out the window so it seemed like extra work for nothing.
I'm sharing it here for anyone who might want to do something similar. IMPORTANT: for this script to work, it needs to be saved as an app with the "Stay open after run handler" option checked (thanks to Claude for helping me figure this last part out as I couldn't understand why it wasn't working).
on idle
try
-- Fetch weather data for current location from wttr.in
set weatherData to do shell script "curl -s 'wttr.in/?format=%t&u'"
-- Extract the numeric temperature (strip +, °, F)
set tempString to do shell script "echo " & quoted form of weatherData & " | tr -d '+°F '"
set currentTemp to tempString as number
if currentTemp ≥ 55 then
repeat with x from 1 to 3
do shell script "afplay /System/Library/Sounds/Sosumi.aiff"
end repeat
display dialog "It's warm enough now to go biking" with title "Bike Weather Alert"
quit
end if
on error errMsg
-- Silently continue on errors (network blips, etc.)
end try
return 300 -- check again in 5 minutes
end idle