[AppleScript] NoDisplaySleepAssertion

Kernelpanik

Herrenhut
Registriert
05.03.04
Beiträge
2.300
Ein kleines Applescript für alle die wie ich, den Computer immer laufen lassen und nur das Display in den Schlaf schicken und sich am nächsten Morgen wundern warum zum Geier der Bildschirm immer noch an ist.

Code:
set {body, switch} to {"", "OFF"}
set var to (do shell script "pmset -g assertions|grep 'PreventUserIdleDisplaySleep'|head -n 1")
set title to (do shell script "echo " & var & "|awk '{print $1}'")
if (do shell script "echo " & var & "|awk '{print $2}'") = "1" then set switch to "ON"
try
    set a to (do shell script "pmset -g assertions|grep 'NoDisplaySleepAssertion'")
    repeat with x in paragraphs of a
        set body to body & x & return & return
    end repeat
end try
if button returned of (display alert title & " is " & switch message body buttons {"Repeat", "OK"}) = "Repeat" then run