AppleScript - changing prefs in a house

Ok guys, so I have a script to disable the "require password on wake" function when I'm at home. He calls my phone to find out if I am connected to the network, and if the lock does not turn on to wake me up. So:

try
do shell script "ping -c2 X.X.X.X"
set theResult to the result
if theResult contains " 2 packets received," then
    tell application "System Events"
        tell security preferences
            get properties
            set properties to {require password to wake:false, require password to unlock:false}
        end tell
    end tell
end if
on error
tell application "System Events"
    tell security preferences
        get properties
        set properties to {require password to wake:true, require password to unlock:true}
    end tell
end tell
end try
end

This works fine, however it requests authentication. I really do not want to use the input text and the return route, as well as the clipboard route, because I do not want the password in the script ... so is there a way to avoid authentication?

+3
source share
2 answers

If your goal is to enable / disable the "password upon waking up" and not run this script without authentication, use

tell application "System Events"
    set require password to wake of security preferences to true
end tell

or

do shell script "defaults write com.apple.screensaver -int 1"

, "false" "-int 0", . , (

~/Library/Preferences/com.apple.screensaver.plist

, , ).

script - , " ", " " "..." . ,

/private/etc/authorization

, .

, , ( ) , : " " , .

+3

:

  • , script, GUI, SecurityAgent, ( ) ; , ,
  • - ( OS X 10.7.4).

Apple rdar://11484075

: Apple Product Security , - ( , , Openradar, Id , , , , Apple ).

+1

All Articles