Posted on 11-15-2013 04:09 PM
First post jamfnation...
With 10.8.X we were able to setup a default dock with the Apps we wanted by modifying and then fixing permission on the plist:
/System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/default.plist
After making the changes we wanted, any new (English speaking) users that would login would get our customized dock. We are a pretty open environment, and I wanted to let the user change their dock like they prefer, so I don't want to enforce any dock items, just build a standard one.
However, with Mavericks this no longer works. I can see that there is now a directory en.lproj instead of the English.lproj, but I would expect that deleting a user's com.apple.dock.plist in /Users/<username>/Library/Preferences and then killing the dock would force it to pull a new copy of the default.plist. Deleting that com.apple.dock.plist is not resetting the dock at all.
Does anyone know where Mavericks is saving a user's dock information? Does anyone know how to add & remove apps from the default dock?
Solved! Go to Solution.
Posted on 11-18-2013 05:10 PM
@gregneagle][/url @freddie.cox][/url Thanks for the responses! My progress and comments:
I agree that editing the source plists are not ideal, but it was the only way I was able to get it working without writing a lot of C code.
cfprefsd is the reason the preferences stay even after the plists are deleted. It is caching a copy into memory and is written back even after deleting the plists. A reboot between changes will pull the new configuration.
While I am using 'defaults' for writing to the file, I am not sure if its the proper form, or how Apple is expecting me to. I basically just add the item to the dock on a test computer and then grab the objects that it wrote into one big string for dropping into a bash script. I was able to get this working (see below). I run a script like it at first boot via Casper Imaging so that all future users get the same dock.
#!/bin/sh
#empty the dock of apps
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array
#empty the dock of other items
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-others -array
#remove the extra junk that apple adds
rm /Library/Preferences/com.apple.dockfixup.plist
#the first app must have an extra key on it
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Launchpad.app</string><key>_CFURLStringType</key><integer>0</integer></dict><key>file-type</key><integer>169</integer></dict></dict>"
#all following apps can follow the same pattern
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Safari.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Mail.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
#put the dock permissions back to their default
chmod 744 /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist
exit 0
Note that the first app in the list has an extra key and integer added onto it.
<key>file-type</key><integer>169</integer>
With 10.8 I had those extra objects on a few of my apps and it still worked, but Mavericks needs it formatted particularly, and so it ignored the whole file.
Thanks for the help on this. Once I got how to update the dock plist, I was able to do incremental testing and solve it.
Posted on 11-15-2013 04:15 PM
See https://developer.apple.com/library/mac/releasenotes/DataManagement/RN-CoreFoundationOlderNotes/
and especially the section on CFPreferences Plist Files. cfprefsd's caching is even more aggressive in Mavericks than it was in Mountain Lion. The upshot is that Mac admins need to stop directly modifying, removing, or replacing preference files.
Posted on 11-15-2013 06:49 PM
I will second @gregneagle on how aggressive cfprefsd is at caching on Mavericks. Even my friend PlistBuddy can't save me from it's clutches. Defaults write will still work with this preference caching, but tends to get a bit ugly with complex changes.
Posted on 11-18-2013 05:10 PM
@gregneagle][/url @freddie.cox][/url Thanks for the responses! My progress and comments:
I agree that editing the source plists are not ideal, but it was the only way I was able to get it working without writing a lot of C code.
cfprefsd is the reason the preferences stay even after the plists are deleted. It is caching a copy into memory and is written back even after deleting the plists. A reboot between changes will pull the new configuration.
While I am using 'defaults' for writing to the file, I am not sure if its the proper form, or how Apple is expecting me to. I basically just add the item to the dock on a test computer and then grab the objects that it wrote into one big string for dropping into a bash script. I was able to get this working (see below). I run a script like it at first boot via Casper Imaging so that all future users get the same dock.
#!/bin/sh
#empty the dock of apps
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array
#empty the dock of other items
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-others -array
#remove the extra junk that apple adds
rm /Library/Preferences/com.apple.dockfixup.plist
#the first app must have an extra key on it
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Launchpad.app</string><key>_CFURLStringType</key><integer>0</integer></dict><key>file-type</key><integer>169</integer></dict></dict>"
#all following apps can follow the same pattern
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Safari.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
defaults write /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Mail.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
#put the dock permissions back to their default
chmod 744 /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist
exit 0
Note that the first app in the list has an extra key and integer added onto it.
<key>file-type</key><integer>169</integer>
With 10.8 I had those extra objects on a few of my apps and it still worked, but Mavericks needs it formatted particularly, and so it ignored the whole file.
Thanks for the help on this. Once I got how to update the dock plist, I was able to do incremental testing and solve it.
Posted on 11-18-2013 05:18 PM
This has been talked about in a bunch of places.
http://hints.macworld.com/article.php?story=20130908042828630 is one.