Update I should note I only partially sorted out getting this to actually work. Probably requires more tinkering and may be best to just go get an app that does the lock/unlock for you.
This procedure is roughly based on Lock Your Mac When Your iPhone Is Out of Range. I’d seen this in the past, but never got around to figuring out how to set it up. Since I’ve got an iPhone with good battery life, leaving Bluetooth on isn’t as scary as it was on my old Android phone, so I thought I’d give it a shot.
I’ve gone the extra steps of figuring out how to retrieve your password from Keychain in order to do the unlock. The sample unlock AppleScript in that post suggests storing your Mac account password in plain text in the script (not so great) and offers that you can save your script as “Run-only” to obfuscate it. I tried that for kicks and while the script itself is obfuscated, your plain text password is still there if you just cat the file.
This is still a work in progress (i.e., I need to actually test it all out), but I wanted to document how I figured out to interact with the Keychain in Lion via shell commands (since the old AppleScript hooks were removed by Apple).
1 2 3
The following assumes you’ve added a password entry to your Mac Keychain named “ProximityAdminPassword” containing your Mac account password.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15