Use gpsfake and gpsd to create a fixed geographical location for geoclue

I am using gnome desktop environment on fedora 34. when I go to various websites in firefox it asks me whether I want to allow location access. I am not sure how to set the location. At some point when I set up gnome clocks time/calendar it got my city. I found the permissions for “privacy” in settings had a section for “location”. I am assuming this has something to do with geoclue which has sections allowing permissions to be set for different applications. Anyway I would like to set up geoclue, but my desktop has NO WIFI which is what the journalctl log shows as the reason geoclue is failing. I noticed geoclue also has a section for “nmea” which is for a “gps” device attached to your computer, usually via usb. Instead of an actual gps device, I want to use the “gpsd” daemon with input from “gpsfake” which just reads a fixed location for my house out of “LOCATION.nmea”. I went to https://www.nmeagen.org/ to generate “LOCATION.nmea” from my address.

edit /etc/geoclue/geoclue.conf to enable nmea and disable wifi.


[agent]
whitelist=geoclue-demo-agent;gnome-shell;io.elementary.desktop.agent-geoclue2
[network-nmea]
enable=true
[wifi]
enable=false
# turn off other agents such as 3g; cdma; modem-gps; 
[geoclue-demo-agent]
allowed=true
system=true
users=
[geoclue-where-am-i]
allowed=true
system=false
users=
[org.gnome.Shell]
allowed=true
system=true
users=
[firefox]
allowed=true
system=false
users=

in first terminal run gpsfake | gpsd pipeline in foreground as root.

$ sudo systemctl enable --now geoclue
$ sudo gpsfake --cycle 4 --clientinit='?WATCH={"enable":true,"json":true}' --pipe --slow -W 0 /root/LOCATION/LOCATION.nmea | gpsd --foreground "tcp://127.0.0.1:2947"

in second terminal run demos/agent in background and attempt to read location.

$ /usr/libexec/geoclue-2.0/demos/agent &
$/usr/libexec/geoclue-2.0/demos/where-am-i
** (where-am-i:7562): CRITICAL **: 12:40:34.080: Failed to connect to GeoClue2 service: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: 'geoclue-where-am-i' disallowed, no agent for UID 1000

I am not having success with this. I am getting the error above.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.