Skip to content

Instantly share code, notes, and snippets.

@cosmin
Created January 14, 2010 05:09
Show Gist options
  • Save cosmin/276895 to your computer and use it in GitHub Desktop.
Save cosmin/276895 to your computer and use it in GitHub Desktop.
# Apple script
# from http://www.macosxhints.com/article.php?story=20070525090946356
set talkTRIES to 0
set TRYCOUNT to 250
# you might need to run sudo touch /private/var/db/.AccessibilityAPIEnabled
# to enable Accessibility API for AppleScript
tell application "System Preferences"
activate
set frontmost to true
tell application "System Events"
tell application process "System Preferences"
click menu item "Security" of menu "View" of menu bar 1
repeat until (window "Security" exists) or (talkTRIES > TRYCOUNT)
set talkTRIES to talkTRIES + 1
end repeat
tell window "Security"
if the value of first checkbox is 0 then
click the first checkbox
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
click the first checkbox
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
end tell
end tell
end tell
quit
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment