Skip to content

Instantly share code, notes, and snippets.

@Retrockit
Created August 5, 2024 16:37
Show Gist options
  • Save Retrockit/3c88022b80dca6bd9f5fe9770cffad1b to your computer and use it in GitHub Desktop.
Save Retrockit/3c88022b80dca6bd9f5fe9770cffad1b to your computer and use it in GitHub Desktop.
Shell Script to turn on Location Services on macos
#!/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