Support geoclue for location provider on LInux
Is your feature request related to a problem? Please describe.
Some devices do not have GPS hardware, or it may not be supported by GPSD. Often times fine location isn't actually required by stellarium, and having course data about your location (i.e. within a few hundred meters) is good enough.
Describe the solution you'd like
It would be great if stellarium could use a location provider that is able to determine some level of location accuracy from sources other than GPS hw (which may not even be present)
Describe alternatives you've considered
Geoclue is a great alternative to gpsd since it can provide some info about a device's location in many more cases than gpsd. From the geoclue wiki:
The aim of project is to utilize all possible sources of geolocation to best find user's location:
WiFi-based geolocation (accuracy: in meters)
GPS(A) receivers (accuracy: in centimeters)
GPS of other devices on the local network, e.g smartphones (accuracy: in centimeters)
3G modems (accuracy: in kilometers, unless modem has GPS)
GeoIP (accuracy: city-level)
https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home
Additional context
Using geoclue would allow stellarium to get location data on more devices (i.e. those without GPS, or GPS hw not supported by gpsd).
Stellarium already supports FreeGeoIP for the cases when GPS is not available. It also seems to use QtPositioning, but only on Windows, not sure why. There exists a GeoClue plugin for QtPositioning.
I think the contributor just had no other platforms to test. But #4221 should open all that, if we can test systems in locations that fail to work as planned.
Hello @craftyguy!
Thank you for suggesting this feature.
@craftyguy can you provide a 1/2 page of setup instructions for geoclue2 to this non-expert? Under which circumstances does it deliver data? What has to be installed, configured, ... It just does not work out of the box. See discussion near the end of #4221. I had trouble on Ubuntu 24.4 and WSL.
@gzotti well, I don't have any clue about WSL and what limitations/difficulties that might introduce esp. if you try to use it with GNSS hardware, modems, and/or wifi devices, so caveats aside this should be enough to start geoclue and maybe get some location data from wifi/AP:
-
install geoclue (
apt install geoclue) -
configure it at
/etc/geoclue/geoclue.conf. Some distros might configure wifi location stuff out of the box, I have no clue what ubuntu does, but just in case you'll want these two things enabled/configured:
[ip]
enable=true
method=ichnaea
[wifi]
enable=true
url=https://api.beacondb.net/v1/geolocate
beacondb.net doesn't have as much info as some of the private databases that map APs to geolocation. The geoclue.conf file should include other examples of services you can use but I think most require an API key. This should be enough for GeoIP to work IIUC.
If you have a GNSS device or a modem, there are other sections in this config for enabling those sources as well, I think most/all are enabled by default though
You may also need to allow stellarium towards the bottom of the config file, with something like:
[stellarium]
allowed=true
system=false
users=
-
start the geoclue agent, on my distro and desktop environment this seems to be XDG autostart activated (
/etc/xdg/autostart/geoclue-demo-agent.desktop) out of the box. You may have to tell your DE to autostart this on login. -
you can test that it's working using the demo app that should have been installed with geoclue (in this response my redacted location was obtained by GeoIP, which is very course but good enough for stellarium):
$ /usr/libexec/geoclue-2.0/demos/where-am-i
Client object: /org/freedesktop/GeoClue2/Client/1
New location:
Latitude: 45.xxxxxx°
Longitude: -122.xxxxxx°
Accuracy: 25000.000000 meters
Description: ipf fallback (from GeoIP data)
Timestamp: Mon Jun 23 17:02:30 2025 (1750723350 seconds since the Epoch)