Hi, I want to deploy an initial default Dock layout after enrollment is completed, where the end user can later change it to whatever suits them.
I’ve heard of multiple methods, such as using Dock items in Jamf Pro settings, scripts, Outset with docklib, and dockutil. I was wondering what the easiest and most hassle-free approach would be as an MDM administrator. Thanks in advance.
Best answer by mvu
We use dockutil in tandem with Jamf Setup Manager.
docktil is easy to setup. Set it, forget it. Users can do whatever with the Dock after.
• Basically two parts. Push the dockutil package. Push a dockutil script that you customize with Dock items you want.
I don’t know the origin of the original script, but here is what I use during enrollment. After it runs, the end-user can modify the dock however they choose.
#!/bin/bash
# --------------------------------------------------------------------------- # Jamf Pro Script: Reset and Rebuild Dock for Logged-In User (macOS-safe) # Uses launchctl asuser + sudo -u (no runuser) # ---------------------------------------------------------------------------
# --------------------------------------------------------------------------- # Wait for Finder and Dock to be running (max wait = 60 seconds) # --------------------------------------------------------------------------- timeout=60 elapsed=0 while true; do finderPID=$($PGREP -x Finder) dockPID=$($PGREP -x Dock)
if [[ -n "$finderPID" && -n "$dockPID" ]]; then echo "Finder (PID: $finderPID) and Dock (PID: $dockPID) are active." break fi
if (( elapsed >= timeout )); then echo "Timeout waiting for Finder/Dock. Proceeding anyway." break fi
echo "Waiting for Finder and Dock... (${elapsed}/${timeout}s)" $SLEEP 2 ((elapsed+=2)) done
# --------------------------------------------------------------------------- # Commands to run as the logged-in user # Note: we set a safe PATH and quote app paths with spaces. # --------------------------------------------------------------------------- read -r -d '' userCommand <<'EOF' export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
# Kill any installer process running killall Installer 2>/dev/null || true sleep 5
/usr/local/bin/dockutil --remove all --no-restart || true sleep 10
/usr/local/bin/dockutil --add "/Applications" --view list --no-restart /usr/local/bin/dockutil --add "~/Desktop" --view list --no-restart /usr/local/bin/dockutil --add "~/Downloads" --view list --no-restart
sleep 5 killall Dock || true EOF
# --------------------------------------------------------------------------- # Execute as the logged-in user in their GUI session # --------------------------------------------------------------------------- echo "Running Dock rebuild as $loggedInUser..." $LAUNCHCTL asuser "$loggedInUID" $SUDO -u "$loggedInUser" /bin/bash -lc "$userCommand" rc=$?
echo "Dock rebuild finished with exit code: $rc" exit $rc
I don’t know the origin of the original script, but here is what I use during enrollment. After it runs, the end-user can modify the dock however they choose.
#!/bin/bash
# --------------------------------------------------------------------------- # Jamf Pro Script: Reset and Rebuild Dock for Logged-In User (macOS-safe) # Uses launchctl asuser + sudo -u (no runuser) # ---------------------------------------------------------------------------
# --------------------------------------------------------------------------- # Wait for Finder and Dock to be running (max wait = 60 seconds) # --------------------------------------------------------------------------- timeout=60 elapsed=0 while true; do finderPID=$($PGREP -x Finder) dockPID=$($PGREP -x Dock)
if [[ -n "$finderPID" && -n "$dockPID" ]]; then echo "Finder (PID: $finderPID) and Dock (PID: $dockPID) are active." break fi
if (( elapsed >= timeout )); then echo "Timeout waiting for Finder/Dock. Proceeding anyway." break fi
echo "Waiting for Finder and Dock... (${elapsed}/${timeout}s)" $SLEEP 2 ((elapsed+=2)) done
# --------------------------------------------------------------------------- # Commands to run as the logged-in user # Note: we set a safe PATH and quote app paths with spaces. # --------------------------------------------------------------------------- read -r -d '' userCommand <<'EOF' export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
# Kill any installer process running killall Installer 2>/dev/null || true sleep 5
/usr/local/bin/dockutil --remove all --no-restart || true sleep 10
/usr/local/bin/dockutil --add "/Applications" --view list --no-restart /usr/local/bin/dockutil --add "~/Desktop" --view list --no-restart /usr/local/bin/dockutil --add "~/Downloads" --view list --no-restart
sleep 5 killall Dock || true EOF
# --------------------------------------------------------------------------- # Execute as the logged-in user in their GUI session # --------------------------------------------------------------------------- echo "Running Dock rebuild as $loggedInUser..." $LAUNCHCTL asuser "$loggedInUID" $SUDO -u "$loggedInUser" /bin/bash -lc "$userCommand" rc=$?
echo "Dock rebuild finished with exit code: $rc" exit $rc
Hi, I am using Jamf Setup Manager, does this require me to install DockUtil on the Setup Manager on behalf of the user first? Also, can I trigger it on the Setup Manager and after login it will just work automatically? Thanks!
What Pat said. So if you set it with a utility (jamf or otherwise) it almost sets a “desired state” of the Dock. If you set it with a script, it’s “one and done”.
Up to you - I’d do some testing though to see what works. IMO if you’re going to let them modify the Dock, then just keep it standard.