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.
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:
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:
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:
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.
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.