Adrian Nier Code

Back to overview

Toggle password protection

Last modification: Tuesday, December 01, 2009 01:50 pm

Toggles the screen saver and sleep mode password protection.

Implementation

on run
   -- Get the current value for the preference setting
   tell application "System Events"
      tell security preferences to set _passwordProtection to require password to wake
   end tell
   
   if _passwordProtection then
      tell application "System Events"
         tell security preferences to set require password to wake to false
      end tell
      
      say "Password protection, off"
   else
      tell application "System Events"
         tell security preferences to set require password to wake to true
      end tell
      
      say "Password protection, on"
   end if
end run