Use Marco Polo or any of the alternatives described on that page to determine your location (change) and execute a shell script that edits ~/Library/Preferences/com.apple.screensaver.plist
:
defaults write com.apple.screensaver askForPasswordDelay -int 1800
Unfortunately, this only takes hold after a re-login. But you can instead use AppleScript for GUI scripting your way through System Preferences:
tell application "System Preferences"
set current pane to pane id "com.apple.preference.security"
tell application "System Events"
tell process "System Preferences"
tell first window
tell first tab group
# ensure we're on the first tab
click (first radio button whose title is "General")
# 'require password' checkbox
set cb to (first checkbox whose title is "Require password")
# 'require password' popup button
set pb to pop up button 1
# always enable password
if value of cb is not 1 then
# password is currently disabled, enable it
click cb
end if
# if password is activated now, set the timeout
# this check is redundant, you can remove it
if value of cb is 1 then
# click pop up button to get menu
click pop up button 1
# select 'immedately'
click first menu item of menu of pb
end if
end tell
end tell
end tell
end tell
quit
end tell
Create three versions of this script for each desired selection from the popup-menu. first menu item
is immediately, second menu item
is 5 seconds, and so on.
Save them as script, e.g. immediately.scpt,
and execute using osascript
from the command line, or save as application from AppleScript Editor, and execute by open
ing them.
Depends on which solution for determining your location you decide to use.
Related post. – Daniel Beck – 2011-05-08T12:52:52.347
Wow. That is amazing. Thanks so much. I really, really need to learn how AppleScript works. – vy32 – 2011-05-10T01:29:15.393
Have you found MarcoPolo to run on 10.6? – vy32 – 2011-05-10T02:02:12.773
@vy32 The web page I linked to discusses issues with 10.6 and links to a google groups discussion where someone offers a patched version that supposedly fixes WiFi issues. – Daniel Beck – 2011-05-10T04:42:59.233