我想让 Macintosh 安全设置位置感知和自动

vy3*_*y32 5 security geolocation macos

我有一台 Macbook Pro,可以从家里带到工作场所、咖啡店和酒店。当我在家时,我希望它不需要密码,除非在 4 小时不活动后。当我旅行时,我希望它在 1 分钟后需要密码,而在工作中我希望它是 30 分钟。

有没有软件可以做到这一点?基本上,我想根据我所在的位置更改屏幕保护程序的设置,并且我希望它根据它关联到的 Wi-Fi 网络自动弄清楚。

Dan*_*eck 1

使用Marco Polo或该页面上描述的任何替代方案来确定您的位置(更改)并执行编辑的 shell 脚本~/Library/Preferences/com.apple.screensaver.plist

defaults write com.apple.screensaver askForPasswordDelay -int 1800
Run Code Online (Sandbox Code Playgroud)

不幸的是,这只有在重新登录后才会生效。但您可以通过系统偏好设置使用 AppleScript 进行 GUI 脚本编写:

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
Run Code Online (Sandbox Code Playgroud)

为弹出菜单中的每个所需选择创建此脚本的三个版本。first menu item是立即,second menu item是 5 秒,依此类推。

将它们另存为脚本,例如并从命令行immediately.scpt,执行,或从 AppleScript 编辑器另存为应用程序,然后通过ing 执行它们。osascriptopen

取决于您决定使用哪种解决方案来确定您的位置。