• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Toggle Screensaver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toggle Screensaver


  • Subject: Re: Toggle Screensaver
  • From: "Adam Bell" <email@hidden>
  • Date: Fri, 17 Feb 2006 19:03:51 -0400

I started using the pmset instructions to induce display sleep (which used to be dim) rather than screensaving a long time ago because it wasn't clear that the ScreenSaverEngine read it's preferences if you didn't invoke the panel. Perhaps it does now.

For immediate effect, you can invoke the screensaver in AppleScript with this instruction:

activate application "ScreenSaverEngine"

and it will start no matter what your setting is. If you leave it set at three minutes n the ScreenSaver pane of Desktop & ScreenSaver, then touching any key turns off the engine and you're back on a three minute schedule. If you want to turn it off it up remotely then

tell application "System Events" to keystroke space

will do it.

On 2/17/06, Stan Cleveland < email@hidden> wrote:
On 2/17/06 Mr Tea < email@hidden> wrote:

> I'm hankering after a script that toggles the interval before the
> screensaver kicks in between three minutes and eternity.


This code uses XMLLib.osax 2.7 from Satimage Software to read/write directly
from/to the screensaver preference plist file. As written, the script
expects to find just one screensaver file in the "ByHost" folder. As pointed
out by John Baltutis, adjust to your system. (OMM there's only one file.)


set prefFolder to ((path to preferences folder) as text) & "ByHost:"
tell application "Finder"
    set plistPath to (first document file of folder prefFolder ¬
        whose name begins with " com.apple.screensaver") as text
end tell
set saverPrefs to prefsRead(plistPath)
if |idleTime| of saverPrefs is 0 then
    set |idleTime| of saverPrefs to 90 -- seconds
else
    set |idleTime| of saverPrefs to 0 -- 0 = eternity
end if
prefsStore(saverPrefs, plistPath)

on prefsRead(plistPath)
    try
        set plistRef to PlistOpen file plistPath
        set thePrefs to PlistGet plistRef
        PlistClose plistRef
    on error number -10 -- file not found
        set thePrefs to {}
    end try
    return thePrefs
end prefsRead

on prefsStore(prefsRecord, plistPath)
    -- overwrites existing file
    set plistRef to PlistNew prefsRecord
    PlistSave plistRef in file plistPath
    PlistClose plistRef
end prefsStore


Stan Cleveland
Color Technology Inc.
Portland, Oregon


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription: email@hidden



--
Some minds remain open long enough for a truth to both enter and leave without processing.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Toggle Screensaver
      • From: kai <email@hidden>
References: 
 >Re: Toggle Screensaver (From: Stan Cleveland <email@hidden>)

  • Prev by Date: Re: Toggle Screensaver
  • Next by Date: Re: do shell script- sed conundrum
  • Previous by thread: Re: Toggle Screensaver
  • Next by thread: Re: Toggle Screensaver
  • Index(es):
    • Date
    • Thread