Automatically lock your computer when you go away

1 minute read

If you are like me, your colleagues like to pown you when you leave your laptop unlocked. Here is a super easy solution to lock your Mac automatically when you leave it: if your cellphone is out of bluetooth range, lock your computer. Easy, efficient.

Here is how to do it:

  • Download Proximity: this application does detect bluetooth devices and lets you launch scripts upon detection or absence of detection (download page here).
  • Copy Proximity.app in /Applications
  • Start the Proximity.app and open its preference panel (the application adds itself to the menu bar next to your clock)
  • Reduce the device monitoring to 30s or so (less time for your colleagues to mess around)
  • Add the device (the device needs to be linked with your computer bluetooth, you can do that in System Preference)
  • Add an AppleScript that will be run when your cellphone goes out of range (see below)
  • Optionally add an AppleScript that will be run when your cellphone goes back in range

The AppleScript to lock your computer is pretty simple. Create a file name out-of-range.scpt and add:

-- out-of-range.scpt

tell application "ScreenSaverEngine" to activate

You can do many more things in these AppleScripts like:

  • change your Adium and Skype status
  • unlock your screen when you come back in range

This other blog entry has a fairly compete setting example. I personally purposely do not unlock the screen when I come back in range. It's safer to ask for the password explicitly incase someone... borrows your cellphone.

Unlike some more complex apps, Proximity is pretty simple and does not let you decide at which range a bluetooth device is considered out-of-range. The good thing is that it is pretty soft on your cellphone battery.

Comments