Git Product home page Git Product logo

corelocationcli's Introduction

CoreLocationCLI

CoreLocationCLI gets the physical location of your device and prints it to standard output. If you move it can also print your updated location. Kill it with CTRL-C.

Usage

Note for Mac users: make sure Wi-Fi is turned on. Otherwise you will see kCLErrorDomain error 0.

Usage

CoreLocationCLI -h
CoreLocationCLI [-follow] [-verbose] [-format FORMAT]
CoreLocationCLI [-follow] [-verbose] -json
Switch Description
-h Display this help message and exit
-follow Continually print location
-verbose Show debugging output
-format FORMAT Print a formatted string with the following specifiers
-json JSON output mode
Format Description
%latitude Latitude (degrees north; or negative for south)
%longitude Longitude (degrees west; or negative for east)
%altitude Altitude (meters)
%direction Degrees from true north
%speed Meters per second
%h_accuracy Horizontal accuracy (meters)
%v_accuracy Vertical accuracy (meters)
%time Time
%address Reverse geocoded location to an address
%name Reverse geocoded place name
%isoCountryCode Reverse geocoded ISO country code
%country Reverse geocoded country name
%postalCode Reverse geocoded postal code
%administrativeArea Reverse geocoded state or province
%subAdministrativeArea additional administrative area information
%locality Reverse geocoded city name
%subLocality additional city-level information
%thoroughfare Reverse geocoded street address
%subThoroughfare additional street-level information
%region Reverse geocoded geographic region
%timeZone Reverse geocoded time zone
%time_local Localized time using reverse geocoded time zone

The default format is: %latitude %longitude.

Output examples

./CoreLocationCLI
50.943829 6.941043
./CoreLocationCLI -format "%latitude %longitude\n%address"
50.943829 6.941043
Kaiser-Wilhelm-Ring 21
	Cologne North Rhine-Westphalia 50672
	Germany
./CoreLocationCLI -json
{"address":"407 Keats Rd\nLower Moreland PA 19006\nUnited States","locality":"nLower Moreland","subThoroughfare":"407","time":"2019-10-03 04:10:05 +0000","subLocality":null,"administrativeArea":"PA","country":"United States","thoroughfare":"Keats Rd","region":"<+40.141196,-75.034815> radius 35.91","speed":"-1","latitude":"40.141196","name":"1354 Panther Rd","altitude":"92.00","timeZone":"America\/New_York","time_local": "2019-10-02 23:10:05 -0400","isoCountryCode":"US","longitude":"-75.034815","v_accuracy":"65","postalCode":"19006","direction":"-1.0","h_accuracy":"65","subAdministrativeArea":"Montgomery"}

Installation

Install the latest release using Homebrew with:

brew install cask corelocationcli

Or build from the command line using the Xcode compiler with one of these commands:

xcodebuild # requires Apple Developer account
# ... or ...
swift build --disable-sandbox -c release # does not require account

Then run your executable from this location:

./.build/arm64-apple-macosx/release/CoreLocationCLI --help

macOS Gatekeeper/Notarization

After trying to run CoreLocationCLI for the first time, the process will be blocked by Gatekeeper, and a system dialog will appear which includes

"CoreLocationCLI" can't be opened because it is from an unidentified developer...

To approve the process and allow CoreLocationCLI to run, go to System Preferences ➡️ Security & Privacy ➡️ General, and look in the bottom right corner for a button to click.

After approving CoreLocationCLI, it should run successfully. For more information, see https://support.apple.com/en-us/HT202491.

Project scope

This project exists to provide a simple tool for getting a device's location. It is expected that this will be composed with other tools or used directly for testing and logging.

The project maintainer was a victim of kidnapping in his past. Meanwhile his laptop was opened by the captors, at the time CoreLocation CLI could have helped to identify the location of his captors. Since then, he continues to maintain the software, he uses the software so it could collect evidence in this situation again, and he is more careful about not getting kidnapped.

Contributing

Considering the project scope, please report any issues at https://github.com/fulldecent/corelocationcli/issues and recommend a fix if possible.

You can fund the project maintainer at https://github.com/sponsors/fulldecent. Even the most modest contribution will surely be noticed.

corelocationcli's People

Contributors

apizz avatar astrocb avatar binford2k avatar daij-djan avatar elyscape avatar fulldecent avatar futuresonus avatar jsejcksn avatar kr4dio avatar purcell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

corelocationcli's Issues

Yosemite and/or authorizationStatus?

I've been trying to get this running, using both the build instructions (built successfully) and the binary download. I'm getting output with authorizationStatus: 0 which implies that I hadn't authorized the app to access location services - but I saw no dialog.

This is also on Yosemite.

In the console log is:
12Nov14 3:31:17.053 PM com.apple.xpc.launchd[1]: (com.apple.CoreLocationAgent[24049]) Endpoint has been activated through legacy launch(3) APIs. Please switch to XPC or bootstrap_check_in(): com.apple.CoreLocation.agent

and then CoreLocation.agent segfaults.

Invoking it again also adds this:
12Nov14 3:32:21.918 PM CoreLocationCLI[24122]: CoreLocation: proxy_WaitForRegistration failed

Unfortunately, C* isn't my forte - I'm more of a sysadmin type. Any ideas of what I could try?

Thanks!

version 2.0.0 seems to ignore format string

sneak@pris:~$ CoreLocationCLI -once YES -format '{ "lat": %latitude, "lon": %longitude }'
<+37.REDACTED,-80.REDACTED> +/- 134.13m (speed -1.00 mps / course -1.00) @ 10/8/16, 00:05:58 Eastern Daylight Time

Update readme to reflect new options

@fulldecent It looks like lines 9 to 79 in the readme didn't get updated in the latest release; it still shows the outdated options information:

## Usage
```sh
CoreLocationCLI -h
CoreLocationCLI [-follow] [-verbose] [-format FORMAT]
CoreLocationCLI [-follow] [-verbose] -json
```
| Switch | Description |
| ---------------- | ------------------------------------------------------ |
| `-h` | Display this help message and exit |
| `-follow` | Continually print location |
| `-verbose` | Show debugging output |
| `-format FORMAT` | Print a formatted string with the following specifiers |
| `-json` | JSON output mode |
| Format | Description |
| -------------- | ---------------------------------------- |
| `%latitude` | Latitude (degrees north; or negative for south) |
| `%longitude` | Longitude (degrees west; or negative for east) |
| `%altitude` | Altitude (meters) |
| `%direction` | Degrees from true north |
| `%speed` | Meters per second |
| `%h_accuracy` | Horizontal accuracy (meters) |
| `%v_accuracy` | Vertical accuracy (meters) |
| `%time` | Time |
| `%address` | Reverse geocoded location to an address |
| `%name` | Reverse geocoded place name |
| `%isoCountryCode` | Reverse geocoded ISO country code |
| `%country` | Reverse geocoded country name |
| `%postalCode` | Reverse geocoded postal code |
| `%administrativeArea` | Reverse geocoded state or province |
| `%subAdministrativeArea` | additional administrative area information |
| `%locality` | Reverse geocoded city name |
| `%subLocality` | additional city-level information |
| `%thoroughfare` | Reverse geocoded street address |
| `%subThoroughfare` | additional street-level information |
| `%region` | Reverse geocoded geographic region |
| `%timeZone` | Reverse geocoded time zone |
| `%time_local` | Localized time using reverse geocoded time zone |
The default format is: `%latitude %longitude`.
## Output examples
```sh
./CoreLocationCLI
```
> ```
> 50.943829 6.941043
> ```
```sh
./CoreLocationCLI -format "%latitude %longitude\n%address"
```
> ```
> 50.943829 6.941043
> Kaiser-Wilhelm-Ring 21
> Cologne North Rhine-Westphalia 50672
> Germany
> ```
```sh
./CoreLocationCLI -json
```
>```json
>{"address":"407 Keats Rd\nLower Moreland PA 19006\nUnited States","locality":"nLower Moreland","subThoroughfare":"407","time":"2019-10-03 04:10:05 +0000","subLocality":null,"administrativeArea":"PA","country":"United States","thoroughfare":"Keats Rd","region":"<+40.141196,-75.034815> radius 35.91","speed":"-1","latitude":"40.141196","name":"1354 Panther Rd","altitude":"92.00","timeZone":"America\/New_York","time_local": "2019-10-02 23:10:05 -0400","isoCountryCode":"US","longitude":"-75.034815","v_accuracy":"65","postalCode":"19006","direction":"-1.0","h_accuracy":"65","subAdministrativeArea":"Montgomery"}
> ```

show error if location access rejected

Right now, after e.g. 10 seconds, it is impossible to determine if corelocationcli if the system is still determining a location or if location access has been blocked.

It would be useful to either get a non-zero exit code if permission has been rejected / location services are turned off.

If this is not possible, a configurable timeout would be helpful.

Error for every operation on OSX Mojave

When I run the program I get:
LOCATION MANAGER ERROR: The operation couldn’t be completed. (kCLErrorDomain error 1.)

My wi-fi is enabled, and I'm connected to the Internet via it.

Os version: Mojave - 10.14.4 (18E227)

Does not work on El Capitan (kCLErrorDomain error 0)

Trying to run CoreLocationCLI I get the following error:
ERROR: The operation couldn’t be completed. (kCLErrorDomain error 0.)

And the following error in the console:
com.apple.xpc.launchd[1]: (com.apple.CoreLocationAgent[1444]) Endpoint has been activated through legacy launch(3) APIs. Please switch to XPC or bootstrap_check_in(): com.apple.CoreLocation.agent

WiFi is turned on.

Default to once

This is confusing too many people. We should default to once.

Work plan:

  • Remove -once option
  • Add -follow option
  • By default follow is false
  • Update documentation for -json that it will disable -follow if they are both selected

Support for Mac OS Monterey

On Mac OS Monterey the installations says

/usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:33:in `block in from_symbol': unknown or unsupported macOS version: :dunno (MacOSVersionError)

can someone adapt it to run with Monterey

A new release is needed. v2.0.0

The latest release CoreLocationCLI 1.0.0 is from Aug 27, 2014 - 4 commits to master since this release.
This is important so that a homebrew formula can be created.
No binary files needed, just code will be fine.

Unable to reset location services prompt after denying

This may not be a problem with CoreLocationCLI, but I wondered if anyone has an idea about what I'm seeing and how to fix it.

I used CoreLocationCLI once during testing, and when I saw the prompt to allow/deny access to location services, I accidentally pressed "deny". Now I can't get the application to prompt again, and there's no entry for CoreLocationCLI in the Security & Privacy->Location Services panel in System Preferences. If there was, I could probably reset it there.

I've tried turning off global location services and reenabling them, but that hasn't helped. Do you have any idea how I can get the program to re-prompt for access to location services?

In case it helps, here is the verbose output from the program:

$ CoreLocationCLI -verbose YES
2017-03-29 16:32:15.969 CoreLocationCLI[5179:11162095] authorizationStatus: 2
2017-03-29 16:32:15.969 CoreLocationCLI[5179:11162095] locationServicesEnabled: 1
2017-03-29 16:32:15.970 CoreLocationCLI[5179:11162095] significantLocationChangeMonitoringAvailable: 0
2017-03-29 16:32:15.970 CoreLocationCLI[5179:11162095] headingAvailable: 0
2017-03-29 16:32:15.970 CoreLocationCLI[5179:11162095] regionMonitoringAvailable: 1
ERROR: The operation couldn’t be completed. (kCLErrorDomain error 1.)

This is on Mac OS X 10.11.6

Documentation: Privacy change for Big Sur (11.x)

For me, I had to go into Settings > Security & Privacy and select the Privacy tab. CoreLocationCLI was listed, but disabled. Clicking on the lock in the lower left let me check the box next to the tool. Worked perfectly after that.

Stop working on macOS Ventura

There are some issues with permissions on Ventura, for some reason is not detected by the location services hence it can not be allowed to run.

Thanks for this great idea!

I've needed to pick the swift files and build a new project, as it needs to be correctly signed.

Couldn't it be done with swift, perhaps, but through the command line?

Running From .plist

macbook pro Monterey 12.6.7
.plist calls the bash script that runs CoreLocationCLI and puts output into a variable and writes to a file. Bash script runs fine on its own. Added a echo "Boo" to the script and prints fine in the file. Your app is called a=$(corelocationcli) as i said works fine when either a user account calls the script or root. Im not sure if the system user (i thought it was a high level user like root) calls the script which calls your app (by the way exchanged CoreLocationCLI for ls -l and that printed ok im lost now dont know why it wouldn't run from a .plist maybe you can help.

[email protected]

Not working on Ventura

I followed the instructions to edit clients.plist and now I get the following error message: The operation couldn’t be completed. (kCLErrorDomain error 0.)

No need to disable "follow" with JSON output

With "follow" enabled, the JSON output effectively becomes jsonlines output, which isn't so bad. This means a stream of output with -json -follow could usefully be read by another program, so it's not helpful to disable that possibility. In fact, I have a use case for which this behaviour would be ideal.

request for new format specifiers

From Richard L. Hamilton

Would it be possible to add format specifiers for human-readable latitude and longitude (using your example, 50º56' 37.78"N and 6º56' 27.75"E ), and perhaps one for newline, so one can enter \n instead of having to actually have a literal newline within quotes, making scripts a bit prettier?

One other that would be awesome: a format specifier to create a google maps URL that would show the location; one can capture the decimal latitude and longitude with a script, and mangle that into a URL, but why not do it all in one place?

broken JSON output

A multi-line address in the JSON output breaks it. Valid JSON requires line breaks to be encoded.

In general, it's considered bad practice not to encode JSON. Always encode it using a library/builtin.

library no loaded libswiftconcats.dylib

I am having a problem running the executable and it is as follows:

library no loaded libswiftconcats.dylib

According to the following link, the problem is due to the fact that the library is not included. In such a way according to the following link I propose to place it in the project to package the library in the project.

Additional option to print decimal coordinates with N|S & E|W

I know this is a weird question, because decimal coordinates are just negative for S & W, but some programs like sunwait need input as decimal, but with N|S and E|W, i.e. in the format 52.516667N 13.388889E instead of 52.516667 13.388889 for Berlin, and 40.7127N 74.0059W instead of 40.7127 -74.0059 for NYC, et cetera. (Same for N vs. S.) I guess I can always parse CoreLocationCLI's output and change it myself, but maybe it isn't too complicated to add an option for an alternate output, e.g. CoreLocationCLI -orientation or CoreLocationCLI -o.

Submit to Homebrew Cask [HELP WANTED]

This app needs to be signed because of the location services. So it appears it will fail in newer versions of normal homebrew and the newest version of macOS.

We will need to submit the binary to https://github.com/caskroom/homebrew-cask

This seems difficult, especially because this is a command line app, not a .app.


Please help with this task if you know how to submit a cask. Here is a start with the information I already have.

Specifically I don't know which stanza (https://github.com/caskroom/homebrew-cask/tree/master/doc/cask_language_reference/stanzas) to use for installing a command line program. That and it would really be helpful if someone with experience can review this and submit.

cask 'corelocationcli' do
  version '2.2.0'
  sha256 'fb59410ee9182c2616303c21f19c783a8afe852b16170dfe3894b0c461bf541e'

  # https://github.com/fulldecent/corelocationcli was verified as official when first introduced to the cask
  url "https://github.com/fulldecent/corelocationcli/releases/download/#{version}/CoreLocationCLI.zip"
  appcast 'https://github.com/fulldecent/corelocationcli/releases.atom',
          checkpoint: 'c31d218a45a4f8e685e573c441ac72aa5c53f68e9966736e95f4f3aab51b927d'
  name 'Core Location CLI'
  homepage 'https://github.com/fulldecent/corelocationcli'
end

Refactor command parameters

There is an established convention for CLI parameters. Here are a few links you can read through to get a basic idea:

Parameters that are a single character should use a single hyphen - so that they can be used together if they don't require values.(e.g. command -abc)

Parameters that are multiple characters should use a double hyphen --. (e.g. CoreLocationCLI --json)

There are also established conventions for parameters like --help, which would be useful for anyone who discovers the program and wants to learn more.

So, you could alias the current mulit-character commands like this:

-h, --help
-v, --verbose

etc.


Here are some suggestions:

-h, --help
-f, --format
-j, --json
-v, --verbose
-V, --version (print version information)
-w, --watch (currently -follow)

f is already used by format, so I suggested -w, --watch. Another idea is -c, --continuous.

CoreLocationCLI times out on Mac OSX 10.14 (mojave)

I have tried to get CoreLocationCLI to work on OSX 10.14 (mojave), but it invariably times out.

Here is the output that appears after about 5 seconds:

CoreLocationCLI
Fetching location timed out. Exiting.

Is the current version of CoreLocationCLI compatible with OSX 10.14?

Documentation needed: Notarization override

See #27 (comment)

It actually does work!:) My bad.
After trying to executing it the first time, go to System Pref --> Security & Privacy --> General and click in the bottom right corner to allow CoreLocationCLI to run. Execute it ones more, it should now run.

I think this needs to be documented in the README.

Any way to print the version number

Is there a way to print CoreLocationCLI's version number?

Something like CoreLocationCLI -version would be nice.

Currently I'm using the file's CRC-32 value to compare a bundled CoreLocationCLI with the version the user has installed.

Can't grant location permissions on MacOs 14 (Sonoma)

I just upgraded to MacOs Sonoma 14.0 Beta (23A5286i). I've been running corelocationCli for many years, and usually when I upgrade OSs I have to reinstall it using Brew. However this time was different.

At first it actually worked just fine for a day. Then it stopped working, and I was getting "The operation couldn’t be completed. (kCLErrorDomain error 0.)" despite wifi being on.

In an attempt to fix the issue, I did my usual of running 'brew reinstall --cask corelocationcli' (so I have the latest version as of 7/18/2023)

Now I'm getting "Location services are disabled or location access denied. Please visit System Preferences > Security & Privacy > Privacy > Location Services"

However, Location services are on. But also, CoreLocationCLI is no longer in the list of things I can enable.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.