Use A Bluetooth Device To Lock And Unlock Your Mac When You're Near

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.

Lock and unlock a Mac using Bluetooth detection [Mac OS X Hints via @Cole_Morgan]


Comments

    I like the idea of securty through the proximity of your phone a neat idea. but i only found this avavilabe for linux and mac computers and not for good old windows users. So after looking around i found something simlar which was also featued on lifehacker. So anyone wanting this on your windows look at the link below

    http://lifehacker.com/372051/btprox-locks-your-workstation-with-your-cell-phone

    Doesn't appear to work with an iPhone 4.. Can't get my phone to connect with my mac via Bluetooth.

    Did some research and found that the iPhone can only connect to headsets only.

    Anyone have any luck getting this to work on an iPhone?

    It works! Just select your iPhone in Proximity's preferences --> Change Device.

    Proximity works correctly, as well as the lock AppleScript code. But the unlock code doesn't work.

    See http://stackoverflow.com/questions/6577635/kill-screensaver-and-unlock-a-mac-using-applescript

    Be warned, Proximity only works with compiled AppleScript code for now (.scpt).

    http://code.google.com/p/reduxcomputing-proximity/issues/detail?id=16&thanks=16&ts=1355771853

    Finally, use ASCII double quotes, not smart quotes. Being able to copy & paste code directly off a website is enormously helpful, whereas presenting code with double quotes is enormously inconvenient.

    If some LifeHacker framework is automatically displaying quotes as smart quotes, consider embedding some JavaScript to convert them back.

Join the discussion!

Trending Stories Right Now