The weather widgets asked wttr.in to geolocate by IP, which lands on
whatever city the ISP registers its address block under -- Downey when
you're in Malibu. Now the location can be set explicitly:
* Click the location in the weather panel to search via open-meteo
geocoding, pick a suggestion (disambiguated by region), and it sticks.
The X next to the field returns to IP auto-detect, as does committing
an empty search.
* State lives in ~/.local/state/omarchy/settings/weather.json as
{name, latitude, longitude}, owned by the new omarchy-weather-location
command (bare call prints the current location, --set/--clear write).
The panel watches the file, so hand edits apply live.
* Stored coordinates make wttr.in and open-meteo exact. Open-meteo also
now supplies current conditions alongside the daily forecast it
already served, which fills the panel within a second of a location
change instead of waiting out wttr.in's multi-second responses; wttr
results still win once they land. Failed wttr fetches retry instead
of sitting stale until the next refresh cycle.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
25 lines
590 B
Bash
Executable File
25 lines
590 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Returns a formatted weather status string with temperature and wind speed.
|
|
|
|
place=$(omarchy-weather-location 2>/dev/null)
|
|
|
|
if [[ -z $place ]]; then
|
|
echo "Weather unavailable"
|
|
exit 1
|
|
fi
|
|
|
|
query=$(jq -rn --arg place "$place" '$place | @uri')
|
|
weather=$(curl -fsS --max-time 4 "https://wttr.in/${query}?format=%t|%w" 2>/dev/null | tr -d '\n')
|
|
|
|
if [[ -z $weather ]]; then
|
|
echo "Weather unavailable"
|
|
exit 1
|
|
fi
|
|
|
|
IFS='|' read -r temperature wind <<< "$weather"
|
|
place=${place^}
|
|
temperature=${temperature#+}
|
|
|
|
echo "$place · Temp $temperature · Wind $wind"
|