Created
August 5, 2024 16:37
-
-
Save Retrockit/3c88022b80dca6bd9f5fe9770cffad1b to your computer and use it in GitHub Desktop.
Shell Script to turn on Location Services on macos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Enable location services and restart the location daemon. | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
# Enable location services. | |
enable_location_services() { | |
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -bool true | |
} | |
# Restart the location daemon. | |
restart_location_daemon() { | |
/bin/launchctl kickstart -k system/com.apple.locationd | |
} | |
main() { | |
local output | |
output=$(enable_location_services && restart_location_daemon 2>&1) | |
echo "${output}" | |
} | |
main "$@" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment