Re: Toggle Screensaver
Re: Toggle Screensaver
- Subject: Re: Toggle Screensaver
- From: Stan Cleveland <email@hidden>
- Date: Fri, 17 Feb 2006 14:46:03 -0800
- Thread-topic: Toggle Screensaver
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:
This email sent to email@hidden