1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -04:00
Files
DankMaterialShell/core/internal/geolocation/client.go
2026-02-27 22:37:10 -05:00

26 lines
626 B
Go

package geolocation
import "github.com/AvengeMedia/DankMaterialShell/core/internal/log"
func NewClient() Client {
geoclueClient, err := newGeoClueClient()
if err != nil {
log.Warnf("Failed to initialize GeoClue2 client: %v", err)
log.Info("Falling back to IP location")
return newIpClient()
}
loc, _ := geoclueClient.GetLocation()
if loc.Latitude != 0 || loc.Longitude != 0 {
return geoclueClient
}
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
}