Description
When setting up a Dock for macOS, applying Dock items via built-in policy can be inconsistent. The dockutil can be used instead following the steps below.
dockutil is a 3rd party solution from github. It has been deployed successfully by organizations using Jamf in the past. Jamf is not affiliated with dockutil.
DockUtil Deployment
Use the dockutil binary and a script to set up the dock.
Download the latest install package for dockutil from the Releases page: https://github.com/kcrawford/dockutil/releases
Upload the package to Jamf Pro. For assistance see Package Management in the Jamf Pro Documentation.
Customize this script to add the Dock Items you want to the user's dock:
#!/bin/sh
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
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 + "\n");')
LoggedInUserHome="/Users/$LoggedInUser"
configureDefaultDock() {
echo "Logged in user is $LoggedInUser"
echo "Logged in user's home $LoggedInUserHome"
if [ -e /usr/local/bin/dockutil ];
then
dockutilVersion=`/usr/local/bin/dockutil --version --version`; echo "dockutil version: $dockutilVersion"
echo "Clearing Dock..."; /usr/local/bin/dockutil --remove all --no-restart "$LoggedInUserHome"
echo "Adding Calendar..."; /usr/local/bin/dockutil --add '/System/Applications/Calendar.app' --no-restart --position 1 "$LoggedInUserHome"
echo "Adding TextEdit..."; /usr/local/bin/dockutil --add '/System/Applications/TextEdit.app' --no-restart --position 2 "$LoggedInUserHome"
echo "Adding Safari..."; /usr/local/bin/dockutil --add '/Applications/Safari.app' --no-restart --position 3 "$LoggedInUserHome"
echo "Adding Applications..."; /usr/local/bin/dockutil --add '/Applications' --no-restart --position 4 "$LoggedInUserHome"
echo "Adding Downloads..."; /usr/local/bin/dockutil --add '~/Downloads' --no-restart --position 5 "$LoggedInUserHome"
touch $LoggedInUserHome/Library/Preferences/com.company.docksetup.plist
else
echo "dockutil not installed, skipping initial dock setup..."
fi
}
configureDefaultDock
killall -KILL Dock
exit 0Please note - Jamf Support does not provide custom scripting support. The script below has worked for organizations in the past. Please deploy in a test environment first.
Add the script to Jamf Pro. For assistance see Scripts in the Jamf Pro Documentation.
Create a policy in Jamf Pro to deploy the package and the script.
In Jamf Pro, go to Computers and click Policies.
Click New and on the General payload complete the following:
Display name
Trigger: recurring check-in
Frequency: once per computer
Click the Packages payload and click Configure.
Click Add for the dockutil install package uploaded previously.
Click the Script payload and click Configure.
Click Add for the script uploaded previously.
Click Scope and add desired computers or computer groups to the scope. It is recommended to test this before deploying to all devices that need the dock reset.
Click Save.