how to script the Energy Saver pref pane ?!

hi,

I am new to apple script, I want to make some changes in my Energy Saver preference Pane. I want to change the time to put the display to sleep etc…

how do I do that ?

can anyone help ? any references?

thanx.

Although the System Preferences application has an AppleScript dictionary, you can’t do much with it. AFAIK, you can’t even tell it to open any given pane, much less manipulate anything within a given pane, like the Energy Saver.

Now you might be able to manipulate the data in the com.apple.preference.energysaver.plist file directly (which is all the Energy Saver pane does anyhow) via an AppleScript do shell script command invoking the terminal command defaults. For more info, do a man defaults from the Terminal.

Another approach might be to do something using the beta UI scripting, if you want to go that way.

Edit: I failed to locate a preference file com.apple.preference.energysaver.plist or equivalent. I still think this approach should work, but it may take some research to figure out how to go about it. For example, executing this line in the Terminal yields some interesting results:

defaults read com.apple.systempreferences

Here’s a partial output, which shows the control panels in the toolbar of my System Preferences:

        "TB Item Identifiers" = (
            "com.apple.prefpane.showall", 
            NSToolbarSeparatorItem, 
            "com.apple.preference.displays", 
            "com.apple.preference.network", 
            "com.apple.preferences.sharing", 
            "com.apple.preference.startupdisk", 
            "com.apple.preference.energysaver", 
            "com.apple.preference.screensaver", 
            "com.apple.preference.universalaccess"
        );