How to identify whether the location services is enabled or not in MAC OS X

Path is to enable the service is System Preference> Security & Privacy >Enable Location Services

  • Is there a command that can be run in the terminal that will provide the state of location services?
  • Is there a plist or other file that is changed when you enable or disable location services?
  • Is there MCX that can be used to control this setting?
  • Is there an entry in the IOKit registry that has this info?

Please provide more information on where the change occurs and then relevance can be written to detect it.


Related:

1 Like

Using fs_usage, it seems to indicate the file on disk is:

/private/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.notbackedup.UUID.plist

Where the UUID is unique to the system. It seems strange to be located in /var/db/locationd, though. 1 is enabled, 0 is disabled.

2 Likes

Thanks @rustymyers !

This will get you the location of that file using relevance: ( only available as ROOT )

files whose(name of it as lowercase starts with "com.apple.locationd." AND name of it as lowercase ends with ".plist") of folders "/private/var/db/locationd/Library/Preferences/ByHost"

On my particular system, there are actually 2 files here, which is a bit odd.

  • com.apple.locationd.UUID.plist
  • com.apple.locationd.notbackedup.UUID.plist

The state of location services should be able to be queried through relevance now that I have the location.

This is what the XML representation looks like on my computer:

<plist version="1.0">
<dict>
	<key>LastSystemVersion</key>
	<string>Mac OS X10.11.3/15D21</string>
	<key>LocationServicesEnabled</key>
	<integer>1</integer>
	<key>ObsoleteDataDeleted</key>
	<true/>
</dict>
</plist>

The relevance should be something like this:

integers "LocationServicesEnabled" of dictionaries of files whose(name of it as lowercase starts with "com.apple.locationd." AND name of it as lowercase ends with ".plist") of folders "/private/var/db/locationd/Library/Preferences/ByHost"

I always forget about that.

1 Like

Thanks @rustymyers & @jgstew for your valuable reply.