Skip to main content

Hi there,



I'm trying the following command to set the screen saver to turn on after 15 minutes:



sudo defaults -currentHost write com.apple.screensaver idleTime -900


Which yielded the proper result:



:~ jkuo$ defaults -currentHost read com.apple.screensaver
{
CleanExit = YES;
PrefsVersion = 100;
idleTime = 900;
moduleDict = {
moduleName = Arabesque;
path = "/System/Library/Screen Savers/Arabesque.qtz";
type = 1;
};
}


It worked right the first time, but then after I changed the setting in system preferences and tried to change it again, it seems like the defaults command doesn't do anything anymore.



:Scripts jkuo$ sudo defaults -currentHost write com.apple.screensaver idleTime -1000
:Scripts jkuo$ defaults -currentHost read com.apple.screensaver idleTime
120


Any ideas what might be happening here?



Thanks!

@jkuo][/url - Managed Preferences may be an alternate method. It's what I have used in the past.


run the command as the user:



sudo su -l "$LoggedInUser" -c "defaults -currentHost write com.apple.screensaver idleTime 1800"

@nkalister][/url - bingo, that did the trick!



Now the next mystery - even though I set it to, say, 30 seconds, the screen saver still isn't turning on after that amount of time. Is there another place I'm missing where I need to change a setting?



Also, even though the defaults read shows 30, in the System Preferences Panel is still shows the last set amount:



jkuo$ defaults -currentHost read com.apple.screensaver idleTime
30


But in System Preferences-->Screen Saver, it says "10 minutes"



Any ideas on what I'm missing here?



Thanks!


well, I've been so annoyed by the unreliability of the screensaver settings that I actually set it at the computer level using MCX as well as for the user with defaults:



# Computer MCX
sleep .5
dscl . -mcxset /Computers/localhost com.apple.screensaver idleTime always -int 1800
dscl . -mcxset /Computers/localhost com.apple.screensaver askForPassword always -int 1
dscl . -mcxset /Computers/localhost com.apple.screensaver askForPasswordDelay always -int 0
# Computer Defaults Writes
sleep .5
sudo su -l "$LoggedInUser" -c "defaults -currentHost write com.apple.screensaver askForPassword -int 1"
sudo su -l "$LoggedInUser" -c "defaults -currentHost write com.apple.screensaver askForPasswordDelay -int 0"
sudo su -l "$LoggedInUser" -c "defaults -currentHost write com.apple.screensaver idleTime 1800"


see if that makes everything look correct . . .
also, I believe you need to at least quit and relaunch SysPrefs before it'll show the new value.


Have you thought about using a profile instead? Something along the lines of this should work for you, just adjust the idleTime to 900. https://github.com/golbiga/Profiles/blob/master/screensaver.mobileconfig



Allen


Sounds like preference caching to me. I had a similar problem with setting icons on the Dock and the Ask For Screen Saver Password when waking a computer from Screen Saver or Sleep. I found that killing the cfprefsd process sometimes fixes it. Other times it takes a reboot. Try adding killall cfprefsd at the end of the script after you run the defaults command.



http://hints.macworld.com/comment.php?mode=view&cid=132659


defaults commands are cfprefsd safe, according to apple, but YMMV.
in my experience with cfprefsd, defaults commands work fine but plistbuddy or replacing the entire plist file will trigger a replacement from cache by cfprefsd.


Reply