9

At the command line, how do I get the current location that geoclue2 would report?

There's no man page or bin/ executable in my Arch package.

redshift (which uses geoclue2) is reporting my location as:

7.98 98.37

But google maps gives me:

9.749160, 99.975484

Is there any way to configure what sources geoclue2 uses to get better accuracy?

Most google geoclue2 searches bring up redshift which isn't too helpful :(

Tom Hale
  • 28,728
  • 32
  • 139
  • 229
  • why geoclue2 only and for what use you need it? – Rui F Ribeiro Nov 05 '18 at 11:40
  • @RuiFRibeiro I currently use it for `redshift`. The `geoclue` doco implies that they should be accurate, so I'm trying to work out why it's not. Also `geoclue` is the only Linux choice for [Mozilla Location Service if not using KDE](https://wiki.mozilla.org/CloudServices/Location/Software) – Tom Hale Nov 05 '18 at 11:55
  • 1
    For applicational use, I prefer the MaxMind databases/geoIP command/APIs. The API itself seems to be fast enough, I have of people feeding the coordinates in the DB to redis. – Rui F Ribeiro Nov 05 '18 at 12:15
  • @RuiFRibeiro Thanks. I'm now using the Google Geolocation API (see my answer) – Tom Hale Nov 06 '18 at 05:45

3 Answers3

6

On Ubuntu 20.04 LTS and newer

Installation:

$ sudo apt install geoclue-2-demo

Execution:

$ /usr/libexec/geoclue-2.0/demos/where-am-i

… and see the scary magic unfold.

A .desktop launcher file is always required for knowing which application IDs to allow. The where-am-i.desktop file is provided at /usr/share/applications/geoclue-where-am-i.desktop

Geolocation sources and allowed applications are configured in /etc/geoclue/geoclue.conf. Application IDs are mentioned without the .desktop file extension.

Serge Stroobandt
  • 2,314
  • 3
  • 32
  • 36
3

To actually answer the question, the geoclue-2.0 Ubuntu package provides a binary at /usr/lib/geoclue-2.0/demos/where-am-i, which will print the location GeoClue reports, as well as the accuracy:

$ /usr/lib/geoclue-2.0/demos/where-am-i
Client object: /org/freedesktop/GeoClue2/Client/12

New location:
Latitude:    1.234000°
Longitude:   1.234000°
Accuracy:    25000.000000 meters
Timestamp:   Sun 21 Jun 2020 17:54:37 BST (1592758477 seconds since the Epoch)
ash
  • 671
  • 6
  • 16
1

On Arch, after installing geoclue the geoclue.service has to be started. For me, accessing the location on Google Maps from within qutebrowser worked. Nothing in the config had to be changed. I did have to wait several minutes, restart the browser, and reopen the page though.

Pound Hash
  • 268
  • 4
  • 14