Dockutil Problems

Chriskmpruitt
Contributor

Ok, so i have been messing around with dockutil for the passed few days. For the most part easy to use and works great.

So I am trying to modify the Default User Template dock plist. In the dockutil --help it says to use the '/System/Library/User Template/English.lproj' plist. But when i go there, i do not have that plist. So I grab the default plist found in /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/.

And change it to com.apple.dock.plist, then push it out to the /System/Library/User Template/English.lproj folder.

Run the dockutil script and get this back

Script result: item Mail was not found in '/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist' item Contacts was not found in '/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist' item Maps was not found in '/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist' item Messages was not found in '/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist' item FaceTime was not found in '/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist' item Photo Booth was not found in '/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist' item iTunes was not found in '/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist' item iBooks was not found in '/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist' Microsoft Outlook already exists in dock. Use --replacing 'Microsoft Outlook' to update an existing item item /Applications/Microsoft Office 2011/Microsoft Outlook.app was not added to Dock Microsoft Word already exists in dock. Use --replacing 'Microsoft Word' to update an existing item item /Applications/Microsoft Office 2011/Microsoft Word.app was not added to Dock Microsoft Excel already exists in dock. Use --replacing 'Microsoft Excel' to update an existing item item /Applications/Microsoft Office 2011/Microsoft Excel.app was not added to Dock Traceback (most recent call last): File "/usr/sbin/dockutil", line 663, in main() File "/usr/sbin/dockutil", line 364, in main if addItem(pl, real_add_path, replace_label, position, before_item, after_item, section, displayas, showas, arrangement, tile_type, label_name): File "/usr/sbin/dockutil", line 516, in addItem if tile_replace_candidate[label_key_for_tile(tile_replace_candidate)] == replace_label: KeyError: None

I am running this in Postimage. My goal is to have the dock modify for new users.

3 ACCEPTED SOLUTIONS

sean
Valued Contributor

Check out the User Template plist file.

defaults read /System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/default.plist

or

defaults read /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist

None of entries have a label eg. "file-label" = Mail
dockutil (with the exception of --add) refers to the label (see 'dockutil -h'). As there isn't one, there is nothing to refer to. If you run

dockutil --list '/System/Library/User Template/English.lproj'

You either see no results or you'll see items you have subsequently added, but you wont see the default Apple items as they have no label. So as suggested, if you wish to remove the items, consider using PlistBuddy to remove the items you don't want.

You could put in a feature request to dockutil to allow for removal of items without labels of course.

View solution in original post

sean
Valued Contributor

Regarding the Traceback error are you removing the persistent-others key from the plist file you are copying to the User Template?

View solution in original post

Mumbler
New Contributor II

'Special' icons like Maps and iBooks are usually part of dockfixup.

https://jamfnation.jamfsoftware.com/discussion.html?id=6081

View solution in original post

12 REPLIES 12

donmontalvo
Esteemed Contributor III

Escaping spaces? :)

Might also want to post here:
https://github.com/kcrawford/dockutil/issues

--
https://donmontalvo.com

babaganouj
New Contributor II

What i've used is the following in a script for Office 2011. Not sure what your script looks like but the error might be that you have issues with adding in the app from /Applications to the English.lproj location?

Hope this helps:

"$3"/usr/local/bin/dockutil --add "$3/Applications/Microsoft Office 2011/Microsoft Word.app" "$3/System/Library/User Template/English.lproj" --no-restart

sean
Valued Contributor

Would help if you post the script

stevewood
Honored Contributor II
Honored Contributor II

I don't think it's the script. I tried just copying the example that is in the dockutil documentation:

dockutil --add /Applications/Firefox.app --after Safari --no-restart '/System/Library/User Template/English.lproj'

And that doesn't work for me. I tried it on an 10.9.3 and a 10.8.5 machine. If you go look in the template folder structure, there is no dock plist file at /System/Library/User Template/English.lproj/Library/Preferences.

I think what I would try, to get around this, would be a LaunchAgent set to run once and destruct. You could then hide a script somewhere on the system that the LaunchAgent would call.

mm2270
Legendary Contributor III

I don't think there's been a com.apple.dock.plist in the User Template Library folder for the couple of OS versions now, so I'm not surprised it doesn't work. I may be wrong, but I don't believe dockutil works like defaults where it will create the plist if the target isn't there. The plist has to be there for the commands to work.

Chriskmpruitt
Contributor

I have put a plist in the User Template for it to work.

Is there a better plist to use?

here is my script @sean

#!/bin/sh

sudo /usr/sbin/dockutil --remove 'Mail' '/System/Library/User Template/English.lproj'
sudo /usr/sbin/dockutil --remove 'Contacts' '/System/Library/User Template/English.lproj'
sudo /usr/sbin/dockutil --remove 'Maps' '/System/Library/User Template/English.lproj'
sudo /usr/sbin/dockutil --remove 'Messages' '/System/Library/User Template/English.lproj'
sudo /usr/sbin/dockutil --remove 'FaceTime' '/System/Library/User Template/English.lproj'
sudo /usr/sbin/dockutil --remove 'Photo Booth' '/System/Library/User Template/English.lproj'
sudo /usr/sbin/dockutil --remove 'iTunes' '/System/Library/User Template/English.lproj'
sudo /usr/sbin/dockutil --remove 'iBooks' '/System/Library/User Template/English.lproj'
sudo /usr/sbin/dockutil --add /Applications/Casper Suite --view grid --display folder '/System/Library/User Template/English.lproj'

killall cfprefsd
killall Dock

exit 0

sean
Valued Contributor

Consider using something like:

# Remove LaunchPad.app
PlistBuddy -c "Delete :persistent-apps:0 dict" /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist
# Remove Notes.app
PlistBuddy -c "Delete :persistent-apps:4 dict" /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist

Before copying the file.

sean
Valued Contributor

Check out the User Template plist file.

defaults read /System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/default.plist

or

defaults read /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist

None of entries have a label eg. "file-label" = Mail
dockutil (with the exception of --add) refers to the label (see 'dockutil -h'). As there isn't one, there is nothing to refer to. If you run

dockutil --list '/System/Library/User Template/English.lproj'

You either see no results or you'll see items you have subsequently added, but you wont see the default Apple items as they have no label. So as suggested, if you wish to remove the items, consider using PlistBuddy to remove the items you don't want.

You could put in a feature request to dockutil to allow for removal of items without labels of course.

sean
Valued Contributor

Regarding the Traceback error are you removing the persistent-others key from the plist file you are copying to the User Template?

Chriskmpruitt
Contributor

@sean][/url, I will give that a try. The way i got it to work right now is just take a blank plist and add the dock items as i want. Then place that into User Template. Works great that way!

I do have this weird thing going on with the dock though. No where in my plist do i have Maps and iBooks. But they just love showing up on every user. Have you ever seen anything like that?I do have this weird thing going on with the dock though. No where in my plist do i have Maps and iBooks. But they just love showing up on every user. Have you ever seen anything like that?

Thank you for all the help guys!

Mumbler
New Contributor II

'Special' icons like Maps and iBooks are usually part of dockfixup.

https://jamfnation.jamfsoftware.com/discussion.html?id=6081

sean
Valued Contributor

As @Mumbler says, dockfixup. We remove them:

defaults delete /Library/Preferences/com.apple.dockfixup add-app