Skip to main content
Solved

Dockutil sets Dock correctly but then users cannot change it


Forum|alt.badge.img+6

We use Dockutil under High Sierra to set the Dock when a user logs in. A policy is scoped to All Users, has a Trigger of Login, and a Scope of once per user per computer. The policy runs the script below. I logged in as myself and the Dock was set correctly. I dragged one App off the Dock and one App onto the Dock. I logged off and back on and the Dock was set back to the default. The App I dragged off was now in the Dock and the App I dragged on was not. Any ideas?

!/bin/sh

/usr/local/bin/dockutil --remove all --no-restart /Users/$3
/usr/local/bin/dockutil --add /Applications/Google Chrome.app --position 1 --no-restart /Users/$3
/usr/local/bin/dockutil --add /Applications/Microsoft Word.app --position 2 --no-restart /Users/$3
/usr/local/bin/dockutil --add /Applications/Microsoft Excel.app --position 3 --no-restart /Users/$3
/usr/local/bin/dockutil --add /Applications/Calculator.app --position 4 --no-restart /Users/$3
/usr/local/bin/dockutil --add /Applications/Dashboard.app --position 5 --no-restart /Users/$3
/usr/local/bin/dockutil --add /Applications/Vmware Horizon Client.app --position 6 --no-restart /Users/$3
/usr/local/bin/dockutil --add /Applications/Photos.app --position 7 --no-restart /Users/$3
/usr/local/bin/dockutil --add /Applications/iTunes.app --position 8 /Users/$3

Best answer by hendersond

I figured it out. I had another policy that runs that add a single item to the Dock. This policy was set to run every time a user logged in. Basically I wanted to make sure one item was always in the Dock. The script behind this other policy was the root cause of the problem. Once I fixed that script, everything worked fine.

View original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+8
  • Contributor
  • 56 replies
  • July 5, 2018

You are likely editing the wrong dock plist depending on how dockutil is being called or depending on how the $3 is resolving, or something else like that.

Try this:

#!/bin/bash

# Include Standard PATH for commands
export PATH=/usr/bin:/bin:/usr/sbin:/sbin

whoami="/usr/bin/whoami"
echo="/bin/echo"
python="/usr/bin/python"
sudo="/usr/bin/sudo"
dockutil="/usr/local/bin/dockutil"
killall="/usr/bin/killall"

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 + "
");')

##########################################################################################
# Check if script is running as root
##########################################################################################
$echo

if [ `$whoami` != root ]; then
    $echo "[ERROR] This script must be run using sudo or as root. Exiting..."
    exit 1
fi

##########################################################################################
# Use Dockutil to Modify Logged-In User's Dock
##########################################################################################
$echo "----------------------------------------------------------------------"
$echo "Use Dockutil to Modify Logged-In User's Dock"
$echo "----------------------------------------------------------------------"
$echo
$echo "Removing all Items from the Logged-In User's Dock..."
$sudo -u $loggedInUser $dockutil --remove all --no-restart

$echo "Creating New Dock..."
$echo
$echo "Adding "Finder"..."

$echo "Adding "Google Chrome"..."
$sudo -u $loggedInUser $dockutil --add "/Applications/Google Chrome.app" --no-restart

$echo "Adding "Microsoft Word"..."
$sudo -u $loggedInUser $dockutil --add "/Applications/Microsoft Word.app" --no-restart

$echo "Adding "Microsoft Excel"..."
$sudo -u $loggedInUser $dockutil --add "/Applications/Microsoft Excel.app" --no-restart

$echo "Adding "Calculator"..."
$sudo -u $loggedInUser $dockutil --add "/Applications/Calculator.app" --no-restart

$echo "Adding "Dashboard"..."
$sudo -u $loggedInUser $dockutil --add "/Applications/Dashboard.app" --no-restart

$echo "Adding "VMware Horizon Client"..."
$sudo -u $loggedInUser $dockutil --add "/Applications/Vmware Horizon Client.app" --no-restart

$echo "Adding "Photos"..."
$sudo -u $loggedInUser $dockutil --add "/Applications/Photos.app" --no-restart

$echo "Adding "iTunes"..."
$sudo -u $loggedInUser $dockutil --add "/Applications/iTunes.app" --no-restart


$echo "Restarting Dock..."
$sudo -u $loggedInUser $killall Dock

exit 0

Forum|alt.badge.img+8
  • Contributor
  • 56 replies
  • July 5, 2018

Oh also, I suggest pulling the commit of Dockutil from GitHub because there have been a few bug fixes added.


Forum|alt.badge.img+6
  • Author
  • Contributor
  • 24 replies
  • July 9, 2018

I am already running Dockutil 2.0.5 which is the latest. I tried the script provided and it sets the Dock correctly but I can still not add items or remove items from the Dock and make it stick. A log off and back and the Dock is back to the default set by Dockutil.
Other ideas?


Forum|alt.badge.img+6
  • Author
  • Contributor
  • 24 replies
  • Answer
  • July 9, 2018

I figured it out. I had another policy that runs that add a single item to the Dock. This policy was set to run every time a user logged in. Basically I wanted to make sure one item was always in the Dock. The script behind this other policy was the root cause of the problem. Once I fixed that script, everything worked fine.


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