I want to make Macintosh Security Settings Location-Aware and Automatic
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.
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.