Enable dock magnification login script

msmith80
New Contributor III

I'm trying to enable the dock magnification when a new user logs in for the first time by putting the following in a login script

defaults write /Users/$3/Library/Preferences/com.apple.dock magnification -boolean TRUE killall Dock

If I manually run it as the user (replacing $3 with username) it works fine. But when I run it as a login script it resets the dock completely. Anyone have a guess, or a better idea at what I am trying to achieve? I don't want to use a configuration profile because I want to allow the user to adjust their settings as they wish.

2 REPLIES 2

mm2270
Legendary Contributor III

My guess is, when you do a defaults write on the user's Dock plist you're changing the ownership to root so when the Dock is killed and restarts, it can't read the plist and loads in a new default one. You need to make sure to set the ownership and permissions correctly on the plist before restarting the Dock if you plan on scripting any changes to it from a Casper Suite policy.

chown $3 /Users/$3/Library/Preferences/com.apple.Dock.plist
chmod 700 /Users/$3/Library/Preferences/com.apple.Dock.plist

Josh_Smith
Contributor III

You could try it this way, this is working for me for a similar function:

loggedInUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`

sudo -u $loggedInUser defaults write com.apple.dock magnification -boolean TRUE

Or modify the user template if you only want to effect new users anyway.

for i in `ls -1 "/System/Library/User Template"`; do
    defaults write "/System/Library/User Template/${i}/Library/Preferences/com.apple.dock.plist" magnification -boolean TRUE
done