Previously mentioned Mac utility Proximity is really handy for performing actions when a Bluetooth connection is made with your Mac and a compatible device. AppleScripter mech14 put together two scripts to use Proximity to lock and unlock your Mac when you’re near by, giving you an awesome Ubuntu-like security system.
Mech14 made the script so it also plays and pauses music when the Bluetooth connection is made, but that’s optional. To get it to work you just need to set his AppleScripts as the actions for Proximity. Here’s the one to unlock your machine:
–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
And the one to lock it:
–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”
Both are downloadable here with a readme file, but check out the full post over on Mac OS X for detailed instructions and customisation options.