Dockutil 1.1.2 issues with 10.8 Mountain Lion

vadanx
Contributor

Just wanted a sanity check.

I was rolling with Dockutil 1.1.2 and 10.7 Lion running a user-owned launch item script that would manage the Dock once per user, per computer. It run beautifully with no issues whatsoever.

Now after testing the exact same script used on 10.8 it either doesn't manage at all, or one or two items from the script are added. Sometimes logging out and back in reveals the fully managed Dock (equiv. to `killall Dock` I guess). If I run the script and view the dock.plist I can see the right keys and values being written, but then almost immediately it gets resorted back by the system to what I set as my default "blank" dock from the base image. (Note: dockutil does run as you see the Dock try to refresh afterwards...)

Has anyone else had issues like this with dockutil and 10.8, if not how do you implement it? Where am I going wrong this time? My script worked perfectly in 10.7. Has anything changed in the 10.8 dock plist that would make the system roll it back and not implement it?

1 ACCEPTED SOLUTION

reto
New Contributor

I had the same problem. The Dock seems to store the previous state and then overwrites `dockutil`'s changes.
Here's a workaround: https://github.com/kcrawford/dockutil/issues/9

View solution in original post

23 REPLIES 23

vadanx
Contributor

Are we meant to keep using the "--no-restarts" option until the end of a long script?

tkimpton
Valued Contributor II

--no-restarts doesnt work for me

mm2270
Legendary Contributor III

Its --no-restart (no "s") in case that's how you were trying it. Works perfectly fine for me in MLion, using dockutil version 1.1.2 as well.
I ran a test with 'dockutil --move 'System Preferences' --position 5 --no-restart'
The Dock stayed as is until I did a 'killall Dock' and System Preferences had moved into the new position as I specified.

@vadanx, perhaps you can post your script or parts of it here? I would think if you are making a lot of modifications to the Dock, it would be best to use the --no-restart option until the end and then restart it. I can't imagine the OS takes kindly to the Dock process being killed repeatedly as changes are made to it.
But, truthfully I only use dockutil as a replacement for the built in jamf binary dock adding option because its much more feature rich. So I'm only doing things like replacing existing icons, or placing new ones next to other applications in the Dock, etc.

vadanx
Contributor

@mm2270

Here's part of the script I run, I didn't actually use the "--no-restart" option before but will try it now and allow the Dock to restart at the end.

#!/bin/sh

# SETTING GLOBAL VARIABLES

currentuser=/usr/bin/stat -f%Su /dev/console pos=0 APPLIST=("/Applications/Lock Screen.app",
"/Applications/Self Service.app",
"/Applications/My Computer Name.app",
"/Applications/Safari.app",
"/Applications/Firefox.app",
"/Applications/Google Chrome.app",
"/Applications/Remote Desktop Connection.app",
"/Applications/Remote Desktop.app",
"/Applications/AS400.app",
"/Applications/TextWrangler.app",
"/Applications/Microsoft Office 2011/Microsoft Word.app",
"/Applications/Microsoft Office 2011/Microsoft Excel.app",
"/Applications/Microsoft Office 2011/Microsoft PowerPoint.app",
"/Applications/Microsoft Office 2011/Microsoft Outlook.app",
"/Applications/Microsoft Lync.app",
"/Applications/Adobe Acrobat 8 Professional/Adobe Acrobat Professional.app",
"/Applications/Adobe Bridge CS5/Adobe Bridge CS5.app",
"/Applications/Adobe Photoshop CS5/Adobe Photoshop CS5.app",
"/Applications/Adobe InDesign CS5/Adobe InDesign CS5.app",
"/Applications/Adobe Illustrator CS5/Adobe Illustrator CS5.app",
"/Applications/Adobe Flash CS5/Adobe Flash CS5.app",
"/Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app",
"/Applications/Adobe Dreamweaver CS5/Adobe Dreamweaver CS5.app",
)
IFS=","

# SETTING LOCAL LOOP VARIABLES AND RUNNING DOCKUTIL IN A "FOR" LOOP

for i in $APPLIST
do
APPNAME=/bin/echo "$i" | /usr/bin/awk -F/ '{print $NF}' | /usr/bin/awk -F. '{print $1}'
pos=expr $pos + 1

/usr/bin/sudo -u $currentuser /usr/bin/dockutil --add "$i" --position $pos

done

~~~

Note: APPNAME is for when I want to remove missing items from the Dock using the label, incase I wanted to run the script routinely to end-users after a downgraded rebuild (I.e. dockutil --remove "$APPNAME", in the for loop)

I'm going to re-write the script to not restart until the very end and see how that goes.

Thanks for the help!

vadanx
Contributor

@tkimpton

Doesn't work for me either, it's seen as not recognised no matter where it's used in the syntax.

If anyone scripts dockutil heavily and it's working in 10.8, I would love to see how you've got it working. It pains me to admit that I may have to resort to another option as we have far too many users to expect them to manage their own docks from scratch...

It was good while it lasted (10.7), too bad I didn't discover this gem sooner.

mm2270
Legendary Contributor III

@vadanx-

So, I downloaded and complied your script and tested on my own 10.8.2 Mac. Here's what I found:

1- dockutil's function that restarts the Dock after making changes to the dock.plist doesn't seem to properly reload the plist file. For example, using 'dockutil --remove all' to get my Dock blanked out, the Dock restarted but all items remained. I tried several times with the same result. However, running a 'dockuil --remove Safari' afterwards returned that Safari didn't exist in the Dock. So then I just did a 'killall Dock' in Terminal and sure enough my Dock was empty save for Finder and Trash.

2 - With your script I edited it to include the applications I have, and added a '--no-restart' to the end of the line in the loop where dockutil is being called. I added a 'killall Dock' at the very end after the 'done' from the loop, and ran it, and voila, all items I specified in the APPLIST appeared in my Dock. And they have remained there since. No reverting back or anything.

So, I think your script works fine under 10.8.2 with dockutil 1.1.2. It just needs a few adjustments to account for the fact that dockutil isn't correctly reloading the plist file when it bounces the Dock. Other than that, it worked great for me. I might even use it to quickly set up a Dock when building new images.

vadanx
Contributor

@mm2270

Go for it! I had it set to run in a LaunchAgent plist owned by the user, so when they logged in for the first time it would manage their Dock once only. It's good to get a second pair of eyes looking at a problem too so thanks for looking in to it!

vadanx
Contributor

@mm2270

Also, if you wanted to use the script to remove items from the Dock, $APPNAME returns the name of the app (missing the .app extension), so you can use it with the '--remove' option.

My original script for 10.7 had checks within each loop that checked; if $i was on the system and not in the Dock, it would add it. If $i was not on the system but in the user's Dock, it would remove (after a system downgrade "?" in the Dock) and if $i was on the system and already in the Dock, it would move it in the Dock to the correct position.

vadanx
Contributor

@mm2270

Could you copy and paste your version of the script? I still get errors when using the '--no-restart' option...

Usage: /usr/bin/sudo -u admin /usr/bin/dockutil --add "/Applications/LockScreen.app" --position 1 --no-restart

Error processing options: option --no-restart not recognized

mm2270
Legendary Contributor III

Sure thing. Here it is. The only other modifications I made to it were with the applist array and also the location of where I have dockutil installed on my systems. And of course the --no-restart and killall Dock at the end.
Hopefully it'll help you.

#!/bin/sh

# SETTING GLOBAL VARIABLES

currentuser=`/usr/bin/stat -f%Su /dev/console` 
pos=0 
APPLIST=("/Applications/Self Service.app",
"/Applications/Safari.app",
"/Applications/Firefox.app",
"/Applications/App Store.app",
"/Applications/VMware Fusion.app",
"/Applications/VMware View Client.app",
"/Applications/Remote Desktop Connection.app",
"/Applications/Microsoft Office 2011/Microsoft Word.app",
"/Applications/Microsoft Office 2011/Microsoft Excel.app",
"/Applications/Microsoft Office 2011/Microsoft PowerPoint.app",
"/Applications/Microsoft Office 2011/Microsoft Outlook.app",
)
IFS=","

# SETTING LOCAL LOOP VARIABLES AND RUNNING DOCKUTIL IN A "FOR" LOOP

for i in $APPLIST
do
APPNAME=`/bin/echo "$i" | /usr/bin/awk -F/ '{print $NF}' | /usr/bin/awk -F. '{print $1}'`
pos=`expr $pos + 1`

/usr/bin/sudo -u $currentuser /usr/sbin/dockutil --add "$i" --position $pos --no-restart

done

sudo killall Dock

I should also mention, as I think I did above, that I blew away all items in the Dock before running the script using dockutil --remove all and then killall Dock to ensure they were all gone.

vadanx
Contributor

@mm2270

Thanks for the reply. The '--remove all' option appears to be the only difference between our scripts.

Will let you know how I do.

vadanx
Contributor

@mm2270

Thanks for the reply. The '--remove all' option appears to be the only difference between our scripts.

Will let you know how I do.

reto
New Contributor

I had the same problem. The Dock seems to store the previous state and then overwrites `dockutil`'s changes.
Here's a workaround: https://github.com/kcrawford/dockutil/issues/9

robo
New Contributor III
New Contributor III

Just noting that the workaround noted above does not work for me any more consistently than without using it (as in, sometimes it works, and sometimes the dock comes up as before and the plist has been reverted).

rmanly
Contributor III

Yea, unfortunately I am going back to using the Casper method (Dock items) of manipulating Docks in place. I still start out with a template dock plist as a baseline.

P.S. If you were robo_ in the ##osx-server room the other day talking about growlnotify I found something awesome ;)

http://brettterpstra.com/2012/08/01/mountain-lion-notifications-from-terminal-with-terminal-notifier...

robo
New Contributor III
New Contributor III

Heh - yes, I was. I'd looked at terminal-notifier and almost went with using it, but in the end I just compiled Growl 2.0.x from source. It's been working well.

rmanly
Contributor III

Nice!

Kumarasinghe
Valued Contributor

We use dockutil 1.1.1 with 10.8.x and this is what we use as a login policy.

IMPORTANT!!!!!
$3 method works reliably with "Perform login actions in background" unticked but NOT when ticked. So please check this;
Go to "Computer Management Framework Settings" > Login/Logout Hooks > Untick "Perform login actions in background" if it is ticked.

#!/bin/bash


# Apply the dockutil settings to current $user

sudo -u $3 /usr/local/bin/dockutil --remove all "/Users/$3"
sudo -u $3 /usr/local/bin/dockutil --add '/Applications/Launchpad.app' "/Users/$3"
sudo -u $3 /usr/local/bin/dockutil --add '/Applications/Safari.app' "/Users/$3"
sudo -u $3 /usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft Word.app' "/Users/$3"
sudo -u $3 /usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft Excel.app' "/Users/$3"
sudo -u $3 /usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft PowerPoint.app' "/Users/$3"
sudo -u $3 /usr/local/bin/dockutil --add '/Applications/Self Service.app' "/Users/$3"
sudo -u $3 /usr/local/bin/dockutil --add '/Applications' --view grid --display folder "/Users/$3"

# Remove
sudo -u $3 /usr/local/bin/dockutil --remove 'App Store' --no-restart "/Users/$3"
sudo -u $3 /usr/local/bin/dockutil --remove 'Reminders' --no-restart "/Users/$3"
sudo -u $3 /usr/local/bin/dockutil --remove 'Notes' --no-restart "/Users/$3"

Also I have edited /Library/Preferences/com.apple.dockfixup.plist file to disable App Store, FaceTime etc apps appear on the Dock.

kstrick
Contributor III

I found with ML, that putting the --no-restart before the --add seemed to fix my issue

vadanx
Contributor

@kstrick

Yesterday I started looking in to this again and found the same as you.

donmontalvo
Esteemed Contributor III

Kyle Crawford released version 1.1.4 a few days ago:

https://github.com/kcrawford/dockutil

--
https://donmontalvo.com

mm2270
Legendary Contributor III

Thanks for the heads up Don. I updated the 3rd party product page with the latest information and version.

Looks like Kyle got around to fixing the Dock restart issue under Mountain Lion according to the notes.

vadanx
Contributor

Thanks Don