Skip to content

feat(statusline): honor user-configured location over IP geolocation (#843)#1309

Open
rpriven wants to merge 1 commit into
danielmiessler:mainfrom
rpriven:feat/statusline-configured-location
Open

feat(statusline): honor user-configured location over IP geolocation (#843)#1309
rpriven wants to merge 1 commit into
danielmiessler:mainfrom
rpriven:feat/statusline-configured-location

Conversation

@rpriven
Copy link
Copy Markdown

@rpriven rpriven commented May 29, 2026

Problem

The statusline determines location and weather purely via ip-api.com IP geolocation, which returns the wrong city for users behind a VPN, proxy, or corporate network whose exit node is in a different city — then falls back to hardcoded San Francisco coordinates. settings.json already has a .location object (city, regionName, lat, lon) but the statusline ignores it for both display and weather.

Fix

Make settings.json .location authoritative when present:

  • Location display uses the configured city / regionName
  • Weather uses the configured lat / lon
  • Optional .location.countryCode drives the flag emoji (falls back to 🌐 when unset)
  • ip-api.com is skipped entirely when location is configured — correct for VPN/proxy users, and one fewer third-party request exposing the user's IP
  • IP geolocation remains the fallback for unconfigured users (no behavior change for them)

The .location.* reads are ?-guarded so a malformed user-edited .location (e.g. a string instead of an object) can't break the rest of the settings cache.

Testing

Tested end-to-end on Debian 13 / PAI v5.0.0:

  • ✅ Configured location with countryCode → shows configured city + flag, skips ip-api
  • ✅ Configured location without countryCode → shows city + 🌐 fallback, skips ip-api
  • ✅ Unconfigured → ip-api fallback works exactly as before (verified countryCode populated from ip-api)
  • ✅ Partial (city only, no coords) → city displays, weather falls back gracefully (no crash)
  • ✅ Malformed .location → guarded; TEMP_UNIT / counts / rest of settings cache intact

Closes #843. Thanks to @DAESA24 for the original analysis and workaround.

…anielmiessler#843)

The statusline determined location/weather purely via ip-api.com IP
geolocation, returning the wrong city for VPN/proxy/corporate-network
users whose exit node differs from their actual location — and falling
back to hardcoded San Francisco coords. settings.json already has a
`.location` object (city/regionName/lat/lon) but the statusline ignored it.

This makes settings.json `.location` authoritative when present:
- Location display uses the configured city/region
- Weather uses the configured lat/lon
- Optional `.location.countryCode` drives the flag emoji (falls back to 🌐)
- ip-api.com is skipped entirely when location is configured (correctness
  for VPN users + one fewer third-party request exposing the user's IP)
- IP geolocation remains the fallback for unconfigured users

The `.location.*` reads are guarded with `?` so a malformed user-edited
location can't break the rest of the settings cache.

Tested end-to-end on Debian 13 / PAI v5.0.0: configured (with + without
countryCode), unconfigured ip-api fallback, partial (city-only → weather
falls back gracefully), and malformed-location paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(statusline): Support user-configured location for weather instead of IP geolocation only

1 participant