Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Macbook Pro that I take from home to work to coffee shops to hotels. When I am at home, I want it to not require a password except after 4 hours of inactivity. When I am traveling, I want it to require a password after 1 minute, and at work I want it to be 30 minutes.

Is there any software that does this? Basically, I want to change settings of the Screen Saver based on where I am, and I want it to figure that out automatically based on which Wi-Fi network it's associated to.

share|improve this question
up vote 1 down vote accepted

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/

defaults write 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 ""
    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
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 opening them.

Depends on which solution for determining your location you decide to use.

share|improve this answer
Related post. – Daniel Beck May 8 '11 at 12:52
Wow. That is amazing. Thanks so much. I really, really need to learn how AppleScript works. – vy32 May 10 '11 at 1:29
Have you found MarcoPolo to run on 10.6? – vy32 May 10 '11 at 2:02
@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 May 10 '11 at 4:42

AirPort Location can snapshot per-location system settings and re-apply them when you use the machine at that location. Check it out to see if it can include the settings you need.

share|improve this answer
It can configure Screen Saver Lock but I was unable to have it change the value to far. – Daniel Beck May 8 '11 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .