An AppleScript to toggle screen saver password
Mon, Jun 4 2007 at 7:30AM PDT • Contributed by: Anonymous
Mon, Jun 4 2007 at 7:30AM PDT • Contributed by: Anonymous
If you want a quick way to toggle your screensaver password with Growl support (to know if it has been enabled or disabled), then try this AppleScript:
[robg adds: Copy and paste the above into Script Editor and save it as an application. Double-click it and you should see Growl messages indicating the change in status (assuming you have Growl installed). Even slicker, use your favorite launcher app to assign a keyboard shortcut to run your script, and you'll have hotkey access to the toggle. This worked perfectly in my testing.]
set output to do shell script "defaults -currentHost read com.apple.screensaver askForPassword -int"
if output is "0" then
do shell script "defaults -currentHost write com.apple.screensaver askForPassword -int 1"
tell application "GrowlHelperApp"
set the allNotificationsList to {"Screensaver Setting"}
set the enabledNotificationsList to {"Screensaver Setting"}
register as application "AppleScript - SSPass" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "System Preferences"
notify with name "Screensaver Setting" title "Screensaver Setting" description "The Screensaver password has been enabled." application name "AppleScript - SSPass"
end tell
else
do shell script "defaults -currentHost write com.apple.screensaver askForPassword -int 0"
tell application "GrowlHelperApp"
set the allNotificationsList to {"Screensaver Setting"}
set the enabledNotificationsList to {"Screensaver Setting"}
register as application "AppleScript - SSPass" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "System Preferences"
notify with name "Screensaver Setting" title "Screensaver Setting" description "The Screensaver password has been disabled." application name "AppleScript - SSPass"
end tell
end if
beep[robg adds: Copy and paste the above into Script Editor and save it as an application. Double-click it and you should see Growl messages indicating the change in status (assuming you have Growl installed). Even slicker, use your favorite launcher app to assign a keyboard shortcut to run your script, and you'll have hotkey access to the toggle. This worked perfectly in my testing.]
•
[10,563 views]
