copy com.apple.dock.plist giving multiple downloads folder

tcandela
Valued Contributor II

I want to have all accounts setup with a default dock so I am modifying a dock and then running the following command ( i don't want to use dockutil or any other utility like that). I did the 'Dock' payload in a policy but it only modifies the dock of existing users, when new users are created they get the default MAC dock.

sudo cp ~/Library/Preferences/com.apple.dock.plist /System/Library/User Template/English.lproj/Library/Preferences

I am also copying it to the desktop and running

sudo cp ~/Desktop/com.apple.dock.plist /System/Library/User Template/English.lproj/Library/Preferences

I create new user accounts and the dock looks good, but to the left of the downloads folder of these new users docks there is an extra 'downloads' plain looking folder with a red circle white line (that locked icon).

the only thing i can think of is it's copying the downloads folder of the original dock i copied. I did a test download of a file and it put the downloaded file in both folders. I am able to access both folders, but its all in one downloads area (it's not creating an extra downloads directory for that user). It's not placing the downloaded file into the downloads directory of the account i copied the .plist from

does anyone have any idea on what is happening and how i can stop this from happening?

7 REPLIES 7

mm2270
Legendary Contributor III

Yes, any user folders, like Downloads, Documents, etc. come from a path that is pointing to the original user the Dock.plist was created on. If you do a defaults read com.apple.Dock against your own plist or point it to the one you're copying over, you should see something like the following in the output, in the section for Downloads.

"_CFURLString" = "file:///Users/username/Downloads/";

where username will be the name of the account that the plist came from. This is why they show up locked. Because the link to the Downloads folder is pointing to an account that isn't the one that's logged in, and it doesn't have read access to.

This is why most of us use utils like dockutil to set these up. Not sure why you don't want to use them. If you're adamant about not using dockutil or some other tools, then I would suggest just leaving Downloads and other user level folders out of the Dock entirely and let the end users add them themselves. The rest should be ok since it should be apps from the main Applications folder.

tcandela
Valued Contributor II

@mm2270 the extra folder it creates is a regular looking folder with the locked icon, but the folder is not actually locked. If i download something, it puts it in both the regular looking folder with locked icon and the regular downloads folder, but when i login to the account that the .plist was copied from, nothing is in the downloads folder.

yep, i did the defaults read ~/Library/ Preferences/com.apple.dock.plist and i see both "_CRURLString" for both of the downloads location

"_CFURLString" = "file:///Users/username/Downloads/";

Im gonna remove the downloads folder from the dock and recopy it to the /System/Library/User Template/English.lproj/Library/Preferences

tcandela
Valued Contributor II

@mm2270 hey, it works.

i did the defaults delete com.apple.dock; killall Dock to reset the dock, and then removed the icons i didn't want (looks like photos,ibook,maps will reapear on the dock for all users no matter if you remove them from the .plist you're copying).

I also remove the 'downloads' folder from the copied dock, then execute the cp command. I created new users and the extra downloads folder (plain looking folder) with the lock icon is not there, only the usual downloads folder for the current logged in user is there.

blackholemac
Valued Contributor III

Gonna offer a suggestion that worked for me...give up on traditional dock management methods from Apple and Jamf and consider using jamf to script a command called dockutil

https://github.com/kcrawford/dockutil

While traditional methods still work, this little tool lets me deploy highly customized docks to various groups of users with minimal headache. Make sure to read the command syntax well and test on a sample machine with the apps installed first by hand. When it works to your liking, use Jamf policies/scripts to manage it.

My script basically checks the machine for the latest build of dockutil, installs it, then meets this instructors specific need. I chose it because it contains a lot of the syntax and thought process I used. This particular script was intended to have an end user run from self service but with minimal modification could be an automated policy that runs on recurring checkin.

#!/bin/sh

# Chesk to see if we have dockutil installed and install it if not
dockutilVersion=$( /usr/local/bin/dockutil --version )
if [[ "$dockutilVersion" != "2.0.5" ]]
then echo "Installing Dockutil 2.0.5"
jamf policy -event dockutilinstall
else echo "Dockutil 2.0.5 already installed" 
fi

# Get the current logged in user that we'll be modifying
user=$(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 + "
");')
echo "Running Dock Configuration on $user"

# Adding potentially non-existent GarageBand folder in the prescribed location before trying to add to dock
if [ ! -d /Users/$user/Music/GarageBand ]
then mkdir /Users/$user/Music/GarageBand
chown -R -f $user:staff /Users/$user/Music/GarageBand
chmod -R -f 700 /Users/$user/Music/GarageBand
fi

# Adding potentially non-existent Logic folder in the prescribed location before trying to add to dock
if [ ! -d /Users/$user/Music/Logic ]
then mkdir /Users/$user/Music/Logic
chown -R -f $user:staff /Users/$user/Music/Logic
chmod -R -f 700 /Users/$user/Music/Logic
fi

# Clear the default dock
echo "Removing all items from the dock"
dockutil --remove all --no-restart /Users/$user
sleep 5

# Adding Application Dock Items in the right order
dockutil --add /Applications/System Preferences.app --no-restart /Users/$user
dockutil --add /Applications/Self Service.app --no-restart /Users/$user
dockutil --add /Applications/Launchpad.app --no-restart /Users/$user
dockutil --add /Applications/Safari.app --no-restart /Users/$user
dockutil --add /Applications/Microsoft OneNote.app --no-restart /Users/$user
dockutil --add /Applications/GarageBand.app --no-restart /Users/$user
dockutil --add /Applications/Audacity/Audacity.app --no-restart /Users/$user
dockutil --add /Applications/Logic Pro X.app --no-restart /Users/$user
dockutil --add /Applications/Finale 2014.5.app --no-restart /Users/$user
dockutil --add /Applications/iTunes.app --no-restart /Users/$user

# Adding folders in the right order
dockutil --add /Users/$user/Documents --view grid --display folder --sort name --no-restart /Users/$user
dockutil --add /Users/$user/Downloads --view grid --display folder --sort name --no-restart /Users/$user
dockutil --add /Users/$user/Music/GarageBand --view grid --display folder --sort name --no-restart /Users/$user
dockutil --add /Users/$user/Music/Logic --view grid --display folder --sort name --no-restart /Users/$user

# Restart the dock after everything is done
sleep 15
killall Dock

mm2270
Legendary Contributor III
(looks like photos,ibook,maps will reapear on the dock for all users no matter if you remove them from the .plist you're copying).

That would be Apple's dockfixup you're running into, or maybe it's called something else now, but yeah, Apple has had a process in place for years now that annoyingly adds in Photos, iBooks and other "Apple" applications to the Dock by default, whether you want them there or not. Because God forbid a new user doesn't know about all of Apple's wonderful programs, so they're gonna force them into your Dock. That's Apple for you.

blackholemac
Valued Contributor III

@mm2270 s issue is exactly why I gave up trying to do things the traditional way. Apple injects the dockfixup, some installers mess with it. Jamf's tools only work well with single dock items and sometimes even when I have it right a dock preference gets corrupted or an Apple update boogers it all up.

I literally gave up and just started using dockutil and have never looked back.

tcandela
Valued Contributor II

the Dock Item payload works for what i'm trying to do, it changes the dock to what i want it to look like (if the user accounts exist when the policy executes), but afterwards if a new user is added and logs in, they get the default Dock. It adds the ibooks, photos, maps (which i don't want, but it's not a big deal).

JAMF should create an option in the Dock items payload that can be checked if they want the Dock items changes to apply to current user accounts only, or current and all future user accounts !!!!!