Fixing GNOME broken geolocation

The bad news, it may be this way forever

Italo Baeza Cabrera
3 min readNov 2, 2024
Photo by Z on Unsplash

For everybody who uses geolocation on their GNOME desktop, and probably some other third-party software that relies on the geoclue library, geolocation hasn’t been working since July.

The reason is simple: Mozilla has sunset their open location services, meaning, you’re no longer able to freely find your geolocation through their API. Any HTTP request is shot down with a 404 “Not Found” error, and it only returns the country, which is pretty much useless.

In other words, if you have a device without GPS, you will not get any accurate

The guys at geoclue haven’t found an alternative that is both free and reliable. Apps that require geolocation are broken, but there is one way to fix it and is not too easy nor convenient.

Also, one caveat: this will mostly work for stationary devices. If you’re on a laptop moving around the city, you’re far better doing the second alternative at the end of the article, but it will cost you.

Goodbye Mozilla

The geoclue library provides a file configuration in etc/geoclue/geoclue.conf. Here you can find an special configuration key that allows geoclue to read static location data from a file.

# Static source configuration options
#
# This source reads location from "geolocation" file in /etc - please
# consult geoclue(5) man page for the format description of this file.
[static-source]

# Enable the static source
# If you make use of this source, you probably should disable other location
# sources in this file so they won't override the configured static location.
enable=true

By setting enable=true, we can create a file with the coordinates at /etc/geoconfig.

The fastest way is to open a compass app from your smartphone, but you may also open your browser to Google Maps, Apple Maps or OpenStreetMap — just be sure to use decimal point to separate decimals. Also, use any website to find your current elevation in meters.

# Latitude (in decimal)
41.33648
# Longitude (in decimal)
2.11697
# Elevation (in meters)
14

Finally, you will need to pinpoint your radius in meters. Setting a radius of 0 (zero) will make the geolocation as accurate as it may be. The higher the radius, the less accurate the geolocation will be.

About that, it depends on your take. If you depend on accurate geolocation for your apps, then by all means zero is the only choice. If you want some kind of privacy, or you move around a given radius, then you can use any number you may deem accurate enough.

# Latitude (in decimal)
41.33648
# Longitude (in decimal)
2.11697
# Elevation (in meters)
14
# Accuracy radius (in meters)
200

Save the file, and that’s it. The geoclue service, if enabled, should pick up the changes automatically, but if you changed the configuration, you would need to restart it.

systemctl restart geoclue.service

Going the Google way

Because Mozilla Location Services doesn’t work anymore, you may use Google Location Services instead. The service is paid, and it’s Google we’re talking about, but for some people it may be a sacrifice.

Simply find this line on the geoclue configuration and uncomment the part where the URL resides in and replace YOUR_KEY with your Google API key for Google Maps.

# WiFi source configuration options
[wifi]

# ...

# To use the Google geolocation service instead of Mozilla's, uncomment this URL
# while changing YOUR_KEY to your Google API key.
#
# WARNING: Please make sure that you are complying with the Google's ToS and
# policies if you uncomment this:
#
# https://developers.google.com/maps/documentation/geolocation/policies
#
url=https://www.googleapis.com/geolocation/v1/geolocate?key=MY_CUSTOM_KEY

Do browsers use my geolocation?

It seems that browsers that have access to your operative system geolocation will try that first instead of pushing a request to their own server.

For example, I tried Google Maps through Firefox and Chrome (both Flatpaks) with geolocation enabled through Flatseal, and both picked up the location I gave to geoclue. When I disabled it, Firefox didn’t pick it up and Edge inaccurately showed me 2 Km away.

It seems that some web services will try their own mechanisms, which may be proprietary databases or open APIs for Wi-Fi if they can’t get geolocation from the operative system.

--

--

Italo Baeza Cabrera
Italo Baeza Cabrera

Written by Italo Baeza Cabrera

Graphic Designer graduate. Full Stack Web Developer. Retired Tech & Gaming Editor. https://italobc.com

No responses yet