- Bluetooth-enabled Mac and a Bluetooth-capable phone (including the iPhone).
- Some AppleScript writing or copying-and-pasting.
- Tested only on 10.5.6 and 10.5.8 install; untested in 10.4 and 10.6.
I frequent various sites such as Gizmodo, Lifehacker, TUAW, macosxhints, and many others, and I was pleasantly surprised to discover that I could have an Ubuntu-like security feature with my iPhone. In Ubuntu, I paired my old Nokia Bluetooth phone with my netbook via BlueProximity, which was a great little app that detected how close I was to my netbook, and either logged me out if I were outside of the proximity field (the phone was not being registered by BlueProximity), or if I came within the proximity field, I’d be seamlessly logged in again without any user intervention. I tried to find a Fink or a MacPort for BlueProximity, but this doesn’t exist. So I left it at that.
I then stumbled across Airlock, which just came out, but unfortunately costs money (~$7) and doesn’t seem to function well -- it generates a lot of false positives where it thinks that you are out of range when in fact you are sitting right in front of the computer.
After a bit more searching, I came across the wonderful little app called Proximity while reading about OS X pranks. Having zero experience with AppleScript, this was a good opportunity to dabble with the code and to find out some great uses for Proximity and AppleScripts. 2br I did some searching for good AppleScripts, modified them, and made the following two scripts that work with Proximity. The first is the inrange script, which runs when your phone is detected:
--tell application "iTunes" to play --This is optional; if you want to play music when you are in the proximity of your computer, it will play ur music. Just delete the 2 minus signs in front of '--tell application "iTunes" to play' tell application "System Events" tell security preferences set require password to wake to false end tell end tell tell application "ScreenSaverEngine" to quit
Next, the outofrange script, which runs when the phone is no longer detected:
--tell application "iTunes" to pause --again, this is optional, but if iTunes is playing, you might want to pause it; delete '--' tell application "System Events" tell security preferences set require password to wake to true end tell end tell -- start screensaver (which locks the screen) activate application "ScreenSaverEngine"
You can download both scripts (along with a Read Me) here.
In an earlier version of this solution, I created an inrange script that had my password explicitly written into the script, and the script simulated typing in a password. This in itself is a security hole, so I found the above method to be a better alternative. I forgot where on Google I've found all the pieces of code that helped me with this, but thanks to those folks that wrote the original scripts on which I based my approach.
I'm new to Applescript writing, but the potential has intrigued me enough that I am now trying to automate pretty much anything I can (things that don't get automated by QuickSilver, that is).
[robg adds: The download link wasn't working when I tried to test it (it's not hosted here on Mac OS X Hints), and I haven't tested these scripts.]

