Calling AppleScript gurus everywhere

June 3, 2008 by Wolfie · 1 Comment
Filed under: Technology 

I’m using the BBC iPlayer to watch a lot of TV at the moment. The problem is that, to get uninterrupted viewing, I have to keep changing my screen saver and display sleep settings (or sit really near the screen so I can keep moving the mouse to keep everything awake).

I found an Apple Script that I’ve edited (very slightly) to allow me to set the screen saver idle time from a simple dialogue box, but I’d like to be able to extend it to also set the display sleep settings as well. Anyone got any ideas how (if) I can do this?

The script I have so far is:

set screenSaverTime to the text returned of (display dialog “Enter screensaver time delay (in seconds)” default answer “300″)

set displaySleepTime to the text returned of (display dialog “Enter display sleep time delay (in seconds)” default answer “900″)

set prefsFolder to (path to “pref”)’s POSIX path & “ByHost/”

tell application “System Events”

set prefsFile to property list file ((folder prefsFolder’s first file where name starts with “com.apple.screensaver.”)’s POSIX path)

tell prefsFile

set value of property list item “idleTIme” to screenSaverTime

end tell

if exists process “System Preferences” then quit application “System Preferences”e

end tell

The idea being that, when I’ve finished watching the program, I can run the script again and the default values will reset the screen saver and display sleep to more normal settings without me having to go back through the System Preferences.

  • Wolfs Stuff

    • See my Amazon Wish List
    • Follow me on Twitter
    • Follow me on FriendFeed
  • Wolfs Helpers