Auto-lock your Mac, and pause your music when you leave your desk.
I’m horrible at locking my workstation at work, and I work in an environment of practical jokers who love to play games with unattented workstations.
My solution? EventScrips and a bit of AppleScripting. The event we are going to watch for is a bluetooth device leaving the area.
I’ve configured the scripts to work with ether Radium or iTunes. whichever is running will get pause and play commands.
Here is the setup:
And here are the AppleScripts, The Last one DisableScreensaverPassword is optional I dont like entering my password every time the screensaver is activated. and when my applescript enables the screensaver it sets the passwrod to wake to true first. So when I’m away a password is required to disable to screensaver. I tried disabling the password and screensaver when the bluetoothe device is recognized again but it turns out OS X gets a bit cranky when you try and adjust security settings while the screensaver is activated.
Lock&Pause:
tell application "System Events"
tell security preferences
set require password to wake to true
end tell
end tell
delay 1
if application "Radium" is running then
tell application "Radium" to pause
end if
if application "iTunes" is running then
tell application "iTunes" to pause
end if
Play:
if application "Radium" is running then
tell application "Radium" to play
end if
if application "iTunes" is running then
tell application "iTunes" to play
end if
DisableScreensaverPassword
tell application "System Events"
tell security preferences
set require password to wake to false
end tell
end tell