Local administrator dock

emclean
New Contributor II

Is there an easy way to set the local administrator dock in os 10.15 that can be pushed out to all laptops when they are enrolled? I would like to get rid of the excess icons and only have a handful that we would use.

3 REPLIES 3

emclean
New Contributor II

I am only wanting Chrome, Terminal, Activity Monitor, Console, Disk Utility, Sublime Text, Batchmod, and settings

cbrewer
Valued Contributor II

You're welcome to take my admin dock script and tweak it for your needs. You'll need a copy of dockutil in /usr/local/bin. Then you'll want to run the script with a login policy limited to your admin user.

#!/bin/bash

# Don't do anything until the Dock has started
if [[ ! $(pgrep -x Dock) ]]; then
  until [[ $(pgrep -x Dock) ]]; do
    echo "Dock not started. Waiting 1 second..."
    sleep 1
  done
  echo "Dock started at: $(date +"%r")"
else
  echo "Dock already started"
fi

sleep 1

# Define variables
user=admin

# Function to create dock URLs
function create_url_items {
  su -l ${user} -c "/usr/local/bin/dockutil --add /Users/${user}/Downloads --label 'Downloads' --position beginning --sort name --no-restart"
  echo "Added Downloads"
  su -l ${user} -c "/usr/local/bin/dockutil --add /Applications --label 'Applications' --position beginning --sort name --no-restart"
  echo "Added Applications"
}

# Function to create application items
function create_app_items {
  if [ -d /Applications/Server.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Server.app --label 'Server' --position beginning --no-restart"
    echo "Added Server"
  fi
  if [ -d /Applications/Self Service.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Self Service.app --label 'Self Service' --position beginning --no-restart"
    echo "Added Self Service"
  fi
  if [ -d /Applications/App Store.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/App Store.app --label 'App Store' --position beginning --no-restart"
    echo "Added App Store"
  fi
  if [ -d /System/Applications/System Preferences.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /System/Applications/System Preferences.app --label 'System Preferences' --position beginning --no-restart"
    echo "Added System Preferences"
  fi
  if [ -d /Applications/System Preferences.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/System Preferences.app --label 'System Preferences' --position beginning --no-restart"
    echo "Added System Preferences"
  fi
  if [ -d /System/Applications/Utilities/Terminal.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /System/Applications/Utilities/Terminal.app --label 'Terminal' --position beginning --no-restart"
    echo "Added Terminal"
  fi
  if [ -d /Applications/Utilities/Terminal.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Utilities/Terminal.app --label 'Terminal' --position beginning --no-restart"
    echo "Added Terminal"
  fi
  if [ -d /System/Applications/Utilities/Migration Assistant.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /System/Applications/Utilities/Migration Assistant.app --label 'Migration Assistant' --position beginning --no-restart"
    echo "Added Migration Assistant"
  fi
  if [ -d /Applications/Utilities/Migration Assistant.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Utilities/Migration Assistant.app --label 'Migration Assistant' --position beginning --no-restart"
    echo "Added Migration Assistant"
  fi
  if [ -d /Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app --label 'Microsoft AutoUpdate' --position beginning --no-restart"
    echo "Added Microsoft AutoUpdate"
  fi
  if [ -d /System/Applications/Utilities/Disk Utility.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /System/Applications/Utilities/Disk Utility.app --label 'Disk Utility' --position beginning --no-restart"
    echo "Added Disk Utility"
  fi
  if [ -d /Applications/Utilities/Disk Utility.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Utilities/Disk Utility.app --label 'Disk Utility' --position beginning --no-restart"
    echo "Added Disk Utility"
  fi
  if [ -d /System/Library/CoreServices/Applications/Directory Utility.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /System/Library/CoreServices/Applications/Directory Utility.app --label 'Directory Utility' --position beginning --no-restart"
    echo "Added Directory Utility"
  fi
  if [ -d /System/Applications/Utilities/Console.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /System/Applications/Utilities/Console.app --label 'Console' --position beginning --no-restart"
    echo "Added Console"
  fi
  if [ -d /Applications/Utilities/Console.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Utilities/Console.app --label 'Console' --position beginning --no-restart"
    echo "Added Console"
  fi
  if [ -d /System/Applications/Utilities/Boot Camp Assistant.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /System/Applications/Utilities/Boot Camp Assistant.app --label 'Boot Camp Assistant' --position beginning --no-restart"
    echo "Added Boot Camp Assistant"
  fi
  if [ -d /Applications/Utilities/Boot Camp Assistant.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Utilities/Boot Camp Assistant.app --label 'Boot Camp Assistant' --position beginning --no-restart"
    echo "Added Boot Camp Assistant"
  fi
  if [ -d /System/Applications/Utilities/Activity Monitor.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /System/Applications/Utilities/Activity Monitor.app --label 'Activity Monitor' --position beginning --no-restart"
    echo "Added Activity Monitor"
  fi
  if [ -d /Applications/Utilities/Activity Monitor.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Utilities/Activity Monitor.app --label 'Activity Monitor' --position beginning --no-restart"
    echo "Added Activity Monitor"
  fi
  if [ -d /Applications/Safari.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Safari.app --label 'Safari' --position beginning --no-restart"
    echo "Added Safari"
  fi
  if [ -d /Applications/Firefox.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Firefox.app --label 'Firefox' --position beginning --no-restart"
    echo "Added Firefox"
  fi
  if [ -d /Applications/Google Chrome.app ]; then
    su -l ${user} -c "/usr/local/bin/dockutil --add /Applications/Google Chrome.app --label 'Google Chrome' --position beginning --no-restart"
    echo "Added Google Chrome"
  fi
}

# Build the Dock

# Delete existing dock items
su -l ${user} -c "/usr/local/bin/dockutil --remove all --no-restart"

# Add new dock items
create_url_items
create_app_items

# Restart Dock
echo "Restarting Dock for ${user}"
su -l ${user} -c "killall Dock"
sleep 5

exit 0

Not applicable

Another way: Get and Learn Dockutil, life is grand with Dockutil