1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-13 09:12:08 -04:00

weather: fix fallback temporarily

This commit is contained in:
bbedward
2026-02-27 22:37:10 -05:00
parent 7bea6b4a62
commit b9e9da579f
6 changed files with 86 additions and 21 deletions

View File

@@ -3,12 +3,23 @@ package geolocation
import "github.com/AvengeMedia/DankMaterialShell/core/internal/log"
func NewClient() Client {
if geoclueClient, err := newGeoClueClient(); err != nil {
geoclueClient, err := newGeoClueClient()
if err != nil {
log.Warnf("Failed to initialize GeoClue2 client: %v", err)
} else {
log.Info("Falling back to IP location")
return newIpClient()
}
loc, _ := geoclueClient.GetLocation()
if loc.Latitude != 0 || loc.Longitude != 0 {
return geoclueClient
}
log.Info("Falling back to IP location")
return newIpClient()
log.Info("GeoClue2 has no fix yet, seeding with IP location")
ipClient := newIpClient()
if ipLoc, err := ipClient.GetLocation(); err == nil {
geoclueClient.SeedLocation(ipLoc)
}
return geoclueClient
}