Skip to content

Remember the weather location per Wi-Fi network - #16615

Open
isc wants to merge 2 commits into
omacom:quattrofrom
isc:weather-location-per-wifi
Open

isc wants to merge 2 commits into
omacom:quattrofrom
isc:weather-location-per-wifi

Conversation

@isc

@isc isc commented Oct 25, 2026 •

Copy link
Copy Markdown

The weather panel finds its city from the network's IP address unless one is pinned, and IP geolocation can be far off. In a village in western France, on Free's network, the same connection is placed in Royan by geo.omarchy.org, in La Rochelle by ipinfo, and the bar showed Chambéry this morning: 110 to 430 km away. Pinning the right city fixes that until the laptop moves: going back and forth between Paris and the countryside, either one city is pinned and wrong half the time, or nothing is pinned and the countryside is wrong all the time. #8440 asks for the same thing: keep home pinned, and auto-detect while travelling.

This makes the pin follow the network. A city picked in the panel while on Wi-Fi is kept for that network, and used whenever the machine is back on it. Any other network auto-detects as it does today. Nothing new to click or translate: it is the same location field.

  • On a network with a city of its own: the panel reports for that city.
  • On any other network: the panel auto-detects through geo.omarchy.org, as today.
  • Off Wi-Fi, and existing pins: a city picked on a wired connection, and every weather.json written before this change, keep applying everywhere a network has no city of its own. Existing files work unchanged.

How a network is recognised

A network is its SSID plus the hardware address of its default gateway, and an entry matches only when both do.

  • The SSID alone is not enough. Every hotel of a chain, every station and every café of a brand shares one, and those are the places where IP geolocation is most often wrong. Two homes can also have a Wi-Fi of the same name.
  • The gateway rather than the access point's BSSID. The gateway is one per place, and the same on a router's 2.4 and 5 GHz bands and behind its repeaters. The BSSID changes from one band or access point to the next, so a city picked upstairs would not hold downstairs.
  • Read without privileges. The gateway comes from ip -j -4 route show default dev <wifi>, or -6 on an IPv6-only network, and its address from ip -j neigh show <gateway>.
  • Until the gateway has answered, the network is unknown. That takes a moment after joining. The panel then auto-detects, and saving a city there is refused rather than stored under an incomplete key.
  • Limit: a phone's hotspot has the same name and the same gateway wherever the phone is, so a city picked on it would follow the phone around. Better not to pick one there.

State

weather.json keeps its shape, and a networks list joins it. Each entry is a location like the top-level one, plus the network's SSID (kept readable for hand edits) and gateway:

{
  "name": "Paris",
  "latitude": 48.85341,
  "longitude": 2.3488,
  "networks": [
    {"ssid": "Cottage", "gateway": "02:00:00:00:00:01", "name": "Lyon", "latitude": 45.74906, "longitude": 4.84789}
  ]
}

Where the location comes from:

Network with an entry Any other network Off Wi-Fi
No top-level location its entry auto-detect auto-detect
Top-level location its entry top-level top-level

Choices

  • One place identifies the network: omarchy-weather-location, which already owns the format. omarchy-weather-location --network prints {"ssid": ..., "gateway": ...} (an empty gateway until it resolves, nothing off Wi-Fi). The panel asks it, so what the panel shows and what it saves can never be keyed differently, and omarchy-weather-status (the bar's right-click), omarchy-weather-icon and the post-boot hook report the same city as the panel without changes.
  • No polling. The panel watches Quickshell.Networking, as the network panel does, and asks for the network only when the machine joins or leaves one. It waits 1.5 s first, the startup reload's existing delay, so a brief drop doesn't flip the location back and forth, and asks again up to three times while the gateway is still unresolved.
  • --set stores the location for this Wi-Fi network when on one, and the top-level location off Wi-Fi, which keeps the per-network entries. On a Wi-Fi network whose gateway hasn't answered yet it refuses and stores nothing; the panel then closes the editor and keeps the location it had. After a save, the panel identifies the network again, so a gateway that answered only after its retries still finds the entry just saved.
  • Clearing (the panel's ✕, or an empty entry) returns this network to auto-detect, which is what the ✕ has always promised. So it forgets this network's entry and the top-level location, which would otherwise still apply here. --clear does the same. Other networks keep their entries, and the file goes away once nothing is left. The alternative, forgetting only this network's entry, would leave an older top-level pin showing and take a second click; and on a laptop that is always on Wi-Fi, there would be no way left to remove that pin from the panel.
  • Resolution stays in Model.js (parseNetwork, and parseLocationFile matching on SSID and gateway), next to the existing parser, with Node tests. The CLI mirrors it in jq, as it already did for the top-level location.

Testing

  • test/shell.d/weather-test.sh: matching in Model.js (same SSID behind another gateway, same gateway under another SSID, gateway not resolved yet, off Wi-Fi), and the CLI against stubbed nmcli and ip (per-network --set, reading, --network, an IPv6-only network, refusing an unidentified network, --clear, removing the file). The new cases fail on quattro.
  • ./test/cli passes.
  • On an Apple Silicon laptop running Omarchy, whose weather files matched quattro's, with this branch's panel and command in the running shell and every request the panel made logged:
    • with a city stored for the current network, the panel fetched that city's coordinates;
    • with the same SSID stored behind another gateway, it auto-detected through geo.omarchy.org instead;
    • with Wi-Fi turned off for 6 s, it fell back to auto-detect about 2 s into the drop; once reconnected, it identified the network within 2 s, the gateway resolved on the first try, and it reported for the stored city again.
  • Not run: the shell suite and the acceptance suite. The location was stored with omarchy-weather-location --set rather than picked in the panel's search field, and the screen was locked during the run, so the panel's look wasn't checked; this change adds nothing to it. The IPv6 fallback and identifying the network again after a save came after that run.

No visible change: the weather panel looks the same and adds no control; it reads the location stored for the current Wi-Fi network instead of a single one.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Weather locations now follow the Wi-Fi network, matched by SSID and gateway address.

  • The location command saves a separate weather city for each Wi-Fi network.
  • The weather panel switches to the city saved for its current Wi-Fi network.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read weather location] --> B{SSID and gateway match?}
  B -->|Yes| C[Use network location]
  B -->|No| D{Top-level location exists?}
  D -->|Yes| E[Use top-level location]
  D -->|No| F[Detect location from IP]
Loading

Reviews (3) · Last reviewed commit: "Identify IPv6-only networks, and the net..." · Reviewed by Greptile

Comment thread shell/plugins/panels/weather/Panel.qml Resolved
Comment thread bin/omarchy-weather-location Resolved
@omarchybot omarchybot added the enhancement New feature or request label Nov 2, 2026
isc and others added 2 commits November 8, 2026 08:39
A city picked in the weather panel on Wi-Fi now holds for that network
only, matched on its SSID and its gateway's hardware address; other
networks auto-detect as before. A city picked off Wi-Fi, or pinned
before this change, still applies everywhere else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An IPv6-only Wi-Fi network had no IPv4 default route, so its gateway
was never found and every city picked there was refused. Fall back to
the IPv6 gateway when there is no IPv4 one.

A gateway that answered only after the panel's retries left the panel
keyed on an empty gateway, so a city saved there was stored but not
shown. Identify the network again after each save.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants