hawkfalcon
hawkfalcon

Reputation: 652

Applescript will not quit automatically

Is there any way I can make it so my script will automatically close? Note: if you force quit it, the screensaver stays on the desktop, so it is not because it is being run within the app.

tell application "System Events"
    tell screen saver preferences
        if running then
            do shell script "killall ScreenSaverEngine"
        else
            do shell script "//System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background"
        end if
    end tell
end tell

Upvotes: 0

Views: 335

Answers (1)

Anne
Anne

Reputation: 27073

Add &> /dev/null & to the shell script:

tell application "System Events"
    tell screen saver preferences
        if running then
            do shell script "killall ScreenSaverEngine"
        else
            do shell script "//System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background  &> /dev/null &"
        end if
    end tell
end tell

Upvotes: 1

Related Questions