Jump to content
JonDigital

[Request] Location Services Toggle

Recommended Posts

Good Morning.  Long time Alfred User/new poster on the forums.  I greatly appreciate all the hard work workflow dev's provide to give us fantastic tools.  I did have a request if you can point me in the right direction.  

 

Is there a workflow to quickly disable/enable location services in OS X Yosemite?  That would be very useful.

 

Thanks in advance!!  

Share this post


Link to post

call this applescript:

 

tell application "System Preferences"

activate

reveal anchor "Privacy_LocationServices" of pane id "com.apple.preference.security"

authorize pane id "com.apple.preference.security"

 

end tell

 

tell application "System Events"

click checkbox "Enable Location Services" of group 1 of tab group 1 of window "Security & Privacy" of application process "System Preferences" of application "System Events"

end tell

 

 

There may be a better way, but Applescript UI scripting (with the authentication when required) is the only way I see to programmatically access Location Services.  If you know of another, calling the script in a workflow is trivial.

Edited by dfay

Share this post


Link to post

call this applescript:

 

tell application "System Preferences"

activate

reveal anchor "Privacy_LocationServices" of pane id "com.apple.preference.security"

authorize pane id "com.apple.preference.security"

 

end tell

 

tell application "System Events"

click checkbox "Enable Location Services" of group 1 of tab group 1 of window "Security & Privacy" of application process "System Preferences" of application "System Events"

end tell

 

 

There may be a better way, but Applescript UI scripting (with the authentication when required) is the only way I see to programmatically access Location Services.  If you know of another, calling the script in a workflow is trivial.

 

Thanks for this bit of info.  I may try messing around with Applescript but I am a huge noob when it comes to this stuff.  Sounds like a fun little project for me.

 

Thanks again!

Share this post


Link to post

If you're going to explore UI scripting in Applescript, this pair of approaches to finding how to refer to items will be a huge help:

 

http://hints.macworld.com/article.php?story=20111208191312748

 

http://apple.stackexchange.com/questions/40436/how-to-know-the-name-of-ui-elements-using-accessibility-inspector-or-any-other

 

The first one there is my preference - that's how I found the anchor and the checkbox in the script above.  Have fun with it!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×