Proximity is an app which can monitor for the presence of a bluetooth device and activate a pre-defined script when that device is in and out of range.
There is a usage guide at makeuseof.com which goes into good detail how to set this up
I have mine setup to do the following when I leave the computer
- Announce the departure verbally
- Set my chat status to away from computer
- Turn off any music which might be playing on spotify and itunes
- ...and finally activate the screensaver which will in turn lock down the mac
This works well and I have one final wish- that conversations initiated on adium can be continued seamlessly on the iphone as soon as proximity is broken.
The following applescripts achieve this
--voice prompt say "The computer is unattended" --set adium status to away tell application "Adium (1.4b4)" go away with message "(walked away)" end tell --find out if spotify and itunes are running tell application "System Events" set iTunes_instances to count (every process whose name is "iTunes") set Spotify_instances to count (every process whose name is "Spotify") end tell --if itunes is playing, pause it if iTunes_instances > 0 then tell application "iTunes" to if player state is playing then playpause end if --close spotify (as there is no way to tell if it is playing) if Spotify_instances > 0 then set ActiveApp to (path to frontmost application as Unicode text) tell application "Spotify" to quit end if -- turn on screensaver tell application "ScreenSaverEngine" to activate --THE UNLOCK SCRIPT tell application "ScreenSaverEngine" to quit tell application "Adium (1.4b4)" go available with message "near computer" end tell say "Franz has returned" tell application "System Events" tell application "Spotify" to activate end tell