I just found a very nice post describing nice things to do with Bluetooth. By using the Proximity tool, my MacBook Pro can monitor the precense of my cell phone. Proximity will run an AppleScript when a selected device enters and/or leaves Bluetooth range. Most  phones are class 2 Bluetooth devices, which gives a range of 10m (outdoors). This allows you to automatically lock your desktop when you leave and unlock when you come back.

Here are the scripts I ended up using on my Leopard (10.5) setup. When entering proximity:

tell application "System Events"
    tell security preferences
        set require password to wake to false
    end tell
end tell
#try
#    tell application id "com.apple.ScreenSaver.Engine" to quit
#end try

When leaving proximity:

tell application "System Events"
    tell security preferences
        set require password to wake to true
    end tell
end tell
tell application id "com.apple.ScreenSaver.Engine" to activate

I combined these scripts with the ones that I use when the MacBook goes to sleep and wakes up. I added “killall Proximity” to the sleep-script and “open /Applications/Utilities/Proximity.app” to the wakeup-script. This way, the proximity is checked right after wakeup.

Update 2009-10-29

The unlock-script doesn’t seem to work on Snow Leopard (10.6)…