Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Change the screen saver's idle time via AppleScript System
The settings in the Desktop & Screen Saver System Preferences panel are among several that don't stick when you move an OS X startup drive to a Mac that you've never connected the drive to before. These settings are at ~/Library » Preferences » ByHost » com.apple.screensaver.0011aa2233cc.plist, where 0011aa2233cc is the Ethernet ID of the Mac's primary Ethernet port (en0), also known as the MAC (Media Access Control) address, which is a number unique to each Mac.

The ByHost folder will gather a collection of plists for other preference panes, applications, etc., all with names containing the Ethernet ID specific to every Mac it's seen. One purpose for this is to allow you to have your user folder stored on a network, letting you have different preferences for each Mac that accesses that home folder. However, this makes it inconvenient when you have a utility drive that you connect to any number of Macs that those Macs haven't seen before. For instance, you'll see that the screen saver kicks in after the default 15 minutes of idle time after you start up the drive on the next Mac, regardless of what setting you chose when the drive was connected to the last Mac you used it with.

This normally requires you to manually open the Desktop & Screen Saver System Preferences panel and change the idle time every time you connect the drive to another Mac that it hasn't seen before. (You don't have to redo these settings if you reconnect the drive to a Mac it's seen before, since the ByHost folder will retain the plists for every Mac it's already seen, unless these files have been trashed.)

But it's possible to change the screen saver's idle time value using a simple one-line AppleScript that the drive launches every time you start it up. (Add the AppleScript to your Login Items list, in the Accounts System Preferences panel.) This solution doesn't require the user (or some clumsy routine) to get the Mac's MAC address first, and it doesn't require naming the plist file by its exact name, with that MAC address, when you write to it. Instead, this makes use of the handy -currentHost command, which calls lookupd to get the current Mac's MAC address for you (obviously it will also work for other plist files in ~/Library » Preferences » ByHost whose name contains the Mac's MAC address). So here's how to set the idle time in Terminal:
defaults -currentHost write com.apple.screensaver idleTime 0
And here's the AppleScript version, for use as a login item:
do shell script "defaults -currentHost write com.apple.screensaver idleTime 0"
But when you need to make changes to more variables in other ByHost plists, this method is more appropriate.
    •    
  • Currently 2.25 / 5
  You rated: 3 / 5 (8 votes cast)
 
[22,127 views]  

Change the screen saver's idle time via AppleScript | 2 comments | Create New Account
Click here to return to the 'Change the screen saver's idle time via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Change the screen saver's idle time via AppleScript
Authored by: johnsawyercjs on Feb 16, '08 01:25:38AM

Note that the plist name quoted in my hint (com.apple.screensaver.0011aa2233cc.plist) is specific to a certain Mac, and yours will be different. The name quoted above may be specific to robg's Mac, since my original hint cited this plist's name as "com.apple.screensaver.MAChash.plist", and pointed out that MAChash was a placeholder for the Mac's MAC address.



[ Reply to This | # ]
Change the screen saver's idle time via AppleScript
Authored by: gerryster on Feb 25, '09 04:52:04AM

Note that the defaults command did not take effect if the System Preferences application is open.

This is helpful to know when watching long videos on your computer. I also use the pmset command to set my Energy Saver preferences to never sleep. This is what I use:

sudo pmset -a -1

-a means apply to battery and outlet powered. -1 loads the custom Energy Saver preferences which in my case all timeouts are set to "Never." I revert this back to normal by using this command:

sudo pmset -a 1

Note that "1" is the "Normal" setting in Energy Saver.

[ Reply to This | # ]