The directory:
/private/var/root/Library/Caches/locationd
contains:
WMM.dat cache.plist clients.plist consolidated.db ephemeris/ glgps_nvs.bin lto2.dat stats.plis
If we run strings
on lto2.dat
, the last line indicates:
BCMLTO33
which hints to a Broadcom Long Term Orbits (LTO) with Assisted-GPS (AGPS) module.
consolidated.db is an sqlite3 database keeping a record of GPS locations. It can be found at:
/private/var/root/Library/Caches/locationd
in order to extract the last known location, one can issue:
/usr/bin/sqlite3 /private/var/root/Library/Caches/locationd/consolidated.db "select latitude,longitude from CellLocation order by Timestamp desc limit 1"
We can trigger activator commands by using an application called TerminalActivator (hopefully updated soon . . .) which acts as a bridge between console commands and Activator.
<?php $pois = array( // add your own POIs to the array new POI(55.761895,37.628174,"notify_post 'Lock Screen'") ); class POI { var $latitude; var $longitude; var $accuracy = 10; var $command; function __construct() { $argc = func_num_args(); $argv = func_get_args(); if(method_exists($this,$cons='__construct'.$argc)) { call_user_func_array(array($this,$cons),$argv); } } function __construct4($la, $lo, $cm, $ac) { $this->latitude = $la; $this->longitude = $lo; $this->command = $cm; $this->accuracy = $ac; } function __construct3($la, $lo, $cm) { $this->latitude = $la; $this->longitude = $lo; $this->command = $cm; } } $db = new PDO('sqlite:/private/var/root/Library/Caches/locationd/consolidated.db'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $q = $db->prepare("SELECT Latitude,Longitude FROM CellLocation ORDER BY Timestamp DESC LIMIT 1"); $q->execute(); $row = $q->fetchObject(); foreach($pois as $poi) { // S = R^2 * (lo_{2}-lo_{1})(sin(la_{1}-sin(la_{2})) if(pow(6371*1000,2) // R_{earth} = 6371 km * abs($row->Longitude-$poi->longitude) * abs(sin($row->Latitude)-sin($poi->latitude)) < $poi->accuracy) { system($poi->command); } } return null; ?>
We can save the PHP script to /usr/local/bin
and create a plist file called com.gpstrigger.plist
in the directory /Library/LaunchDaemons
that will run every hour and check whether our location is within the accuracy range of any POIs:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.gpstrigger</string> <key>ProgramArguments</key> <array> <string>/usr/bin/php</string> <string>/path/to/gpstrigger.php</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>3600</integer> </dict> </plist>
We can program TerminalActivator to trigger any Activator action but any terminal commands are possible.
For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.