Skip to main content
Question

Enable dock magnification login script


Forum|alt.badge.img+5

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

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • April 25, 2016

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

Forum|alt.badge.img+14
  • Contributor
  • 270 replies
  • April 26, 2016

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

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings