Kennwort-Abfrage nach Standby switchen

Manchmal möchte man eine Kennwort-Abfrage nach dem Ruhezustand und manchmal eben nicht. Um das schnell umzuschalten:

— hubionmac.com 04.02.2011

— script that toggles “require password after standby / screensaver”-checkbox 

— Status is reported via dialog or growl if installed

— links: http://hintsforums.macworld.com/showthread.php?p=591189

— http://www.macosxautomation.com/applescript/features/system-prefs.html

— http://growl.info/documentation/applescript-support.php

tell application “System Events”

tell security preferences

if (get require password to wake) = false then

set require password to wake to true

my display_message(“Require password switched on”, 2)

else

set require password to wake to false

my display_message(“Require password switched off”, 2)

end if

end tell

end tell

on display_message(msgTXT, msgTimeout)

tell application “System Events”

set isRunning to ¬

(count of (every process whose name is “GrowlHelperApp”)) > 0

end tell

if isRunning = true then

tell application “GrowlHelperApp”

— Make a list of all the notification types 

— that this script will ever send:

set the allNotificationsList to ¬

{“Status”}

— Make a list of the notifications 

— that will be enabled by default.      

— Those not enabled by default can be enabled later 

— in the ‘Applications’ tab of the growl prefpane.

set the enabledNotificationsList to ¬

{“Status”}

— Register our script with growl.

— You can optionally (as here) set a default icon 

— for this script’s notifications.

register as application ¬

“Finder” all notifications allNotificationsList ¬

default notifications enabledNotificationsList ¬

icon of application “Finder”

Send a Notification…

notify with name ¬

“Status” title ¬

“Status” description ¬

msgTXT application name ¬

“Finder”

return true

end tell

else

activate

display dialog msgTXT giving up after msgTimeout

end if

end display_message

Was ich eigentlich am besten daran finde ist die display_message-Routine die ggf. growl nutzt. Ich würde nämlich ehr das hier nutzen…

Nice2Know

Sollte man mal über das Terminal die Einstellungen ändern wollen, sind die anderen Einstellungen in einer XML-Datein unter /etc/authorizationabgespeichert…. Bei Änderungen ist ein vorheriger Backup ECHT RATSAM!

Leave a Reply