Ask / Submit

How to access geolocation from command line?

asked 2015-01-17 11:34:38 +0300

tobixen gravatar image

updated 2015-01-19 11:05:01 +0300

eric gravatar image

I'd like to get access to my position and gps data from the command line - surely that must be possible?

edit retag flag offensive close delete

4 Answers

Sort by » oldest newest most voted

answered 2015-01-17 18:30:31 +0300

kimmoli gravatar image

updated 2015-01-18 22:06:05 +0300

when maps is running, following command gives you lat,long

dbus-send --session --type=method_call --print-reply \
    --dest=org.freedesktop.Geoclue.Providers.Here \
    /org/freedesktop/Geoclue/Providers/Here \

something like

method return sender=:1.918 -> dest=:1.979 reply_serial=2
 int32 3
 int32 1421521856
 double 61.2342
 double 23.5406
 double nan
 struct {
    int32 5
    double 135.2
    double nan

maybe there is way to enable it also from command line, but didn't yet figure it out.

(Couldn't find a way to send a{sv} aka QVariantMap from cli)

edit flag offensive delete publish link more


Any idea on how to do it w/o Here/Maps, i.e. just having the GPS enabled in Settings?

foss4ever ( 2015-01-18 05:43:19 +0300 )edit

Propably most efficient way would be to make a simple commandline tool for this purpose. Or maybe search internet for such written for Qt ?

kimmoli ( 2015-01-18 10:17:45 +0300 )edit

answered 2015-01-18 22:31:40 +0300

kimmoli gravatar image

Made small commandline app called position (also a learning project).

Altough i requested updates every second, it updates every 30 sec (?)


You can find readybuilt binary from mer obs (link valid for version 0.0.3)

edit flag offensive delete publish link more


While developing GPSInfo I was also seeing this "problem" about the interval, it seems to be something like a minimum. While there is no GPS fix, you will get updates containing the last known location in a lower interval, but if the GPS is available you will get updates as soon as they are available.

balta ( 2015-01-19 09:46:58 +0300 )edit

Yep, also noticed the same thing when working on modRana. Until it gets a real GPS fix, it uses some alternative approximate method to get a preliminary fix every 30 seconds.

This alternative method is most probably WiFi an/or mobile cell positioning using a remote service over the Internet - you send it the WiFi AP MAC addresses/mobile cell ids and it tells you your approximate coordinates.

And the 30 second interval is mot probably rate limiting so that all the Jollas (and other devices) using the API don't DDoS it out of existence or there could be some usage quotas Jolla bought for the API, etc.

Also given the approximate nature of the coordinates returned (tens of meters in best case, which is still quite good actually), it won't make much sense to run another request sooner, unless you are currently moving.

MartinK ( 2015-01-19 14:10:37 +0300 )edit

thanks. So in Jolla there is no way to have GPS position unless maps app is open?

I am interested in writing an app to track when I go into or out of a specific geographic area and I need continuous GPS fix for it to work ( 2015-01-20 14:14:22 +0300 )edit

Is it possible to compile this on the Jolla?

Rolfa ( 2016-05-24 11:34:27 +0300 )edit

answered 2018-12-05 16:53:05 +0300

slowcyclist gravatar image

updated 2018-12-05 16:54:07 +0300

Late answer to the question, but I made a python script that actually starts the gps by itself and prints the gps coordinates. It does not need another application to be running, in contrast to the other answers.

You can get it from here

edit flag offensive delete publish link more

answered 2015-01-18 03:27:09 +0300

marsch gravatar image

Posted a howto some months ago which describes an approach based on cell location:

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools



Asked: 2015-01-17 11:34:38 +0300

Seen: 2,515 times

Last updated: Dec 05 '18