Posted on 03-30-2021 04:26 AM
I am using a script that works using DockUtil to manage our Docks. It will only create the standard Mac dock on the first login. All subsequent logins correctly work. We are on MacOS 11.2.3. I have used this successfully on 10.13.
I have changed the script priority to before and after. I have it set to trigger on login and enrollment complete and it is set to an ongoing execution frequency.
This is the script that runs on login for every user:
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 + " ");')
$echo
if [ $whoami
!= root ]; then
$echo "[ERROR] This script must be run using sudo or as root. Exiting..."
exit 1
fi
$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
/bin/sleep 2
$echo "Creating New Dock..."
$echo
$echo "Adding "Finder"..."
$sudo -u $loggedInUser $dockutil --add "/Applications/Adobe Animate CC 2019/Adobe Animate 2019.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Adobe Illustrator CC 2019/Adobe Illustrator.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Adobe Lightroom Classic/Adobe Lightroom Classic.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Adobe Photoshop CC 2019/Adobe Photoshop CC 2019.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Adobe Premiere Pro CC 2019/Adobe Premiere Pro CC 2019.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Audacity.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/System/Applications/Calculator.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Corel Painter 2016/Corel Painter 2016.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/FontForge.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/GarageBand.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Google Chrome.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Google Earth Pro.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/iMovie.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Keynote.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/LibreOffice.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Managed Software Center.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Microsoft Excel.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Microsoft OneNote.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Microsoft Outlook.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Microsoft PowerPoint.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Microsoft Word.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Mount FS1 10.11.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/System/Applications/Music.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/NaturalReader 16.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Numbers.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/OpenShot Video Editor.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Pages.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/System/Applications/Photos.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Poser 10/Poser 10.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Safari.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Shotcut.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/Sibelius 7.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/SMART Technologies/Notebook.app" --no-restart
$sudo -u $loggedInUser $dockutil --add "/Applications/VLC.app" --no-restart
$echo "Restarting Dock..."
$sudo -u $loggedInUser $killall Dock
exit 0
Posted on 03-30-2021 05:18 AM
I recommend to use the JAMF function "Dock Items" inside a policy for setting up the users Dock. I am using this to configura a "company dock" on all clients at their rollout.
To be able to use the policy, you have first to register all items of a dock, you will touch. This must be done at: "Computer Management" | "Dock Items"
After that, You will be able to remove Dock Items (which are already registered in "Dock Items") and set Dock Items (which are already registered at "Dock Items").
The trigger for the policy can be set at the mainpage of the policy.
Hint:
You also can use a configuration profile to setup a Dock, but using this option, the user will not be able to change the Docksettings, you made. This is the reason, why we are creating the dock with a policy. Here, the user can change the dock settings.
Posted on 04-19-2021 06:03 AM
The problem with the Dock Items method is it doesnt run until the policy is refreshed on the device. So for a new login, it isnt triggered for a while. That doesnt work for us, since in lab settings different users login to random computers all the time.
Posted on 04-25-2021 11:09 PM
@mmajewski : We are running the policy right after deploying our standard software and it is running well. There is no need for a further login. After enroll a client, the standard software will be deployed to the client and after the deployment is successful finished, the filevault process starts. Because of the filevault process, there is another login neccessary, but the dock was recreated, before.
Posted on 04-26-2021 07:01 AM
Try adding some code at the start that waits for the Dock process to be running before attempting changes.
# 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
Also, edit your post so that the script is formatted as a script - makes it much easier for others to review your code.
Posted on 04-26-2021 07:25 AM
For my labs where I want a standard Dock, I loaded the com.apple.Dock.json from https://github.com/Jamf-Custom-Profile-Schemas/joshua-d-miller-schemas on a Configuration Profile, added the Apps I want and then scoped to the appropriate computers. This way I can avoid waiting for any triggers as profiles install right away.
Posted on 04-27-2021 11:55 AM
DockBuilder was something I wrote a while back to solve this problem. It might be due for an update, but should still function.