Dockutil montery

Ryan-G
New Contributor

Anyone got a script for Dockutill on Monterey. Our old Python script doesn't work anymore. We are looking to keep the Self Service app permanently in the dock. 

 

This is the current script. 

#!/bin/sh

DOCKUTIL=/usr/local/bin/dockutil

sleep 10

$DOCKUTIL --add '/Applications/Self Service.app' --replacing 'Self Service' --no-restart /Users/$3

killall cfprefsd

killall Dock

exit 0

2 ACCEPTED SOLUTIONS

Tapia
New Contributor III

Here is a more complete view of how I am using this. 

 

We use the Remove feature to trim down the Music, AppleTV, PodCasts, etc apps. 

 

 

USERNAME=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
dockutil="/usr/local/bin/dockutil"

#remove stuff
sudo -u $USERNAME $dockutil --remove all --no-restart --allhomes

#add stuff
sudo -u $USERNAME $dockutil --add '/System/Applications/Launchpad.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Self Service.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Google Chrome.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Microsoft Excel.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Microsoft Word.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Microsoft PowerPoint.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Slack.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/zoom.us.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/System/Applications/System Settings.app' --no-restart --allhomes

#add folders
sudo -u $USERNAME $dockutil --add '/Applications/' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '~/Downloads/' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '~/Documents/' --no-restart --allhomes

#kill Dock
sudo killall Dock

View solution in original post

cbrewer
Valued Contributor II

Are you triggering your Dock script at login? If so, it helps to add code to your Dock script to have it not do anything until the Dock is actually loaded. Put this ahead of any of your dockutil commands. Here is what I use:

# 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

 

View solution in original post

5 REPLIES 5

Tapia
New Contributor III

This is what I use. I start by removing everything from the dock then adding what I desire. Be mindful some Applications' paths changed in Monterey/Ventura. It may be easiest to just drag the Application to Terminal then copy the path. One example would be "/System/Applications/ System Settings.app" (Also, this is called Settings in Ventura instead of Preferences)

 

*I realize I should not need sudo when pushing from Jamf.

 

 

#!/bin/bash

USERNAME=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')

dockutil="/usr/local/bin/dockutil"

#remove stuff

sudo -u $USERNAME $dockutil --remove all --no-restart --allhomes

#add stuff

sudo -u $USERNAME $dockutil --add '/Applications/Self Service.app' --no-restart --allhomes

#kill Dock

sudo killall Dock

Ryan-G
New Contributor

We don't want to remove anything, we just want to add self service, i removed the section about #remove stuff. but this then added self service which is great, but removed everything else. 

Tapia
New Contributor III

Here is a more complete view of how I am using this. 

 

We use the Remove feature to trim down the Music, AppleTV, PodCasts, etc apps. 

 

 

USERNAME=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
dockutil="/usr/local/bin/dockutil"

#remove stuff
sudo -u $USERNAME $dockutil --remove all --no-restart --allhomes

#add stuff
sudo -u $USERNAME $dockutil --add '/System/Applications/Launchpad.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Self Service.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Google Chrome.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Microsoft Excel.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Microsoft Word.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Microsoft PowerPoint.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/Slack.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/Applications/zoom.us.app' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '/System/Applications/System Settings.app' --no-restart --allhomes

#add folders
sudo -u $USERNAME $dockutil --add '/Applications/' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '~/Downloads/' --no-restart --allhomes
sudo -u $USERNAME $dockutil --add '~/Documents/' --no-restart --allhomes

#kill Dock
sudo killall Dock

cbrewer
Valued Contributor II

Are you triggering your Dock script at login? If so, it helps to add code to your Dock script to have it not do anything until the Dock is actually loaded. Put this ahead of any of your dockutil commands. Here is what I use:

# 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

 

Ryan-G
New Contributor

Thanks all for your help, I have now managed to get this working.