Skip to content

Instantly share code, notes, and snippets.

@thadd
Created July 29, 2013 22:36
Show Gist options
  • Save thadd/6108523 to your computer and use it in GitHub Desktop.
Save thadd/6108523 to your computer and use it in GitHub Desktop.
This Applescript checks to see if you're away from home and sets OS X to require a password if you're out. If you're at home, no password is required. It requires Location Helper to work (free on the app store). I also recommend Lingon to make it easy to setup the repeating task in launchd. Just set your home address and run this periodically.
tell application "Location Helper"
set home_address to geocode address "123 Main St., Anytown, US"
set location to location of geometry of item 1 of results of home_address
set home_coordinates to {lat of location, lng of location}
set distance to get distance from coordinates home_coordinates
if distance > 500 then
set away_from_home to true
else
set away_from_home to false
end if
tell application "System Events"
set require password to wake of security preferences to away_from_home
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment