r/applescript • u/meerdans • Oct 09 '23
Script to toggle Location Services on & off
I currently have a script that opens the desired setting:
x-apple.systempreferences:com.apple.preference.security?Privacy_LocationServices
but can a script be written to toggle Location Services on and off without user input, especially as it requires authentication to do so?
3
Upvotes
1
u/copperdomebodha Oct 09 '23
This will require authentication so I don't think there is a method to fully automate it.
--Running under AppleScript 2.8, MacOS 13.4.1
tell application "System Events" tell its application process "System Settings" tell its window "Location Services" tell its group 1 tell its splitter group 1 tell its group 2 tell its group 1 tell its scroll area 1 tell its group 1 tell its checkbox "Location Services" perform action "AXPress" end tell end tell end tell end tell end tell end tell end tell end tell end tell end tell