3

I am looking for a way to automatically login to my computer when waking from sleep/startup when I am at my home/connected to my home wifi; but when for example I am at school or not connected to my home wifi require a password.

I am running El Capitan 10.11 Beta (15A278b) on a MacBook Pro (Retina 15 inch mid-2015)

1

I’ve configured my system to do something similar to what you are trying to do. While I personally never disable my login password (I never recommend doing it for several reasons) I do change some of my security settings for my local home network vs. when I’m away from home.

First, you will want to get and install ControlPlane (which I have NOT tested with El Capitan). This add-on will let you change a bunch of settings on your Mac based on the location information that it can glean from "evidence sources”. It also has a bunch of built in functions, is AppleScriptable, and open source.

Once you have ControlPlane installed you will need to create an AppleScript that will let you disable or enable password login based on the location information.

The AppleScript you create may be different depend on which Mac OS you are running (in your case El Capitan). But it will be similar to the script I created on OS X 10.9.5 to do what you want.

NOTE 1: This scrip only toggles the settings found on the Security & Privacy Page, it does NOT have any understanding of the location information. You will probably want to create a version of this AppleScript for each location that ControlPlane identifies, and have it change the settings accordingly.

NOTE 2: This script require the user to enter their administrative password twice when disabling the password login and screensaver settings. I don’t know of a way around this unless you want to drop down and do shell scripting from ControlPlane, or add your password into the AppleScript and have it type it in for you.

I DO NOT GUARANTEE OR WARRANTY THIS SCRIPT! USE AT YOUR OWN RISK AS I HAVE NOT TESTED WITH EL CAPITAN.

-- !!! USE THIS SCRIPT AT YOUR OWN RISK !!!
-- !!! NO IMPLIED OR EXPLICIT GUARANTEES OR WARRANTIES ARE MADE !!!
-- USE OF THIS SCRIPT IS NOT GUARANTEED TO WORK ON ALL OS VERSIONS!

-- An AppleScript to Disable and Enable automatic login and sleep/screen saver password request.
-- This script may require the user to enter their administrative password twice when disabling.
-- This script ONLY toggles the settings found on the Security & Privacy page.

tell application "System Preferences"
    activate
    set current pane to pane id "com.apple.preference.security"
    delay 1
    tell application "System Events"
        tell process "System Preferences"
            click menu item "Security & Privacy" of menu "View" of menu bar 1
            delay 0.5

            -- Check to see if the System Prefs are locked and editing is disabled.
            if title of checkbox 1 of window 1 is "Click the lock to make changes." then
                click checkbox 1 of window 1
                repeat until checkbox "Click the lock to prevent further changes." of window 1 exists
                    delay 0.1
                end repeat
            end if

            -- This should enable or disable "Disable automatic login"
            click checkbox "Disable automatic login" of tab group 1 of window 1
            repeat until not (exists sheet 1 of window 1)
                delay 0.1
            end repeat
            delay 0.5

            -- This should enable or disable "Require password after sleep or screen saver begins"
            click checkbox 1 of tab group 1 of window 1
            delay 0.25
            repeat until not (exists sheet 1 of window 1)
                click button "Turn Off Screen Lock" of sheet 1 of window 1
            end repeat
            delay 0.25
            -- BE CARFULE IF YOU CHANGE THIS AS IT COULD MODIFY YOUR KEYCHAIN!!!
            repeat until not (exists sheet 1 of window 1)
                click button "Keep Using Keychain" of sheet 1 of window 1
            end repeat

        end tell
    end tell
    tell application "System Preferences" to quit
end tell



If you use this scrip as an AppleScript app MAKE SURE that your Accessibility settings are enabled, otherwise it won’t work. enter image description here

You must log in to answer this question.

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