Posted on 07-19-2023 10:42 PM
Guys, sorry to reopen the thread. I've macOS of 13.4.1(c) and trying to deploy the customised dock using
the below script. When I manually execute the script in terminal, it is getting executed successfully
but nothing appearing in the dock even after kill the dock. Kindly advice.
#!/bin/zsh
# dockutil path
dockutil="/usr/local/bin/dockutil"
# Exit if Dockutil is not installed
if [[ ! -f ${dockutil} ]]; then
echo "dockutil is not installed. Existing..."
exit 1
fi
# Get major macOS Version
os_version=$(sw_vers -productVersion | awk -F. '{print $1}')
# Wait for the Dock
while ! pgrep -x "Dock" >/dev/null 2>&1; do
echo "Waiting for Dock..."
sleep 1
done
# Get the username of the currently logged in user
username=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
# Cleanup Dock
/usr/local/bin/dockutil --remove all --no-restart /Users/"${username}"
# Add applications
/usr/local/bin/dockutil --add "/Applications/Self Service.app" --no-restart /Users/"${username}"
/usr/local/bin/dockutil --add "/System/Applications/Launchpad.app" --no-restart /Users/"${username}"
if [[ ${os_version} -ge 13 ]]; then
/usr/local/bin/dockutil --add "/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app" --no-restart /Users/"${username}"
else
/usr/local/bin/dockutil --add "/Applications/Safari.app" --no-restart /Users/"${username}"
fi
/usr/local/bin/dockutil --add "/Applications/Google Chrome.app" --no-restart /Users/"${username}"
/usr/local/bin/dockutil --add "/Applications/Firefox.app" --no-restart /Users/"${username}"
/usr/local/bin/dockutil --add "/Applications/Microsoft Word.app" --no-restart /Users/"${username}"
/usr/local/bin/dockutil --add "/Applications/Microsoft Excel.app" --no-restart /Users/"${username}"
/usr/local/bin/dockutil --add "/Applications/Microsoft PowerPoint.app" --no-restart /Users/"${username}"
/usr/local/bin/dockutil --add "/Applications/Microsoft Outlook.app" --no-restart /Users/"${username}"
/usr/local/bin/dockutil --add "/Applications/Microsoft Teams.app" --no-restart /Users/"${username}"
/usr/local/bin/dockutil --add "/Applications/Microsoft OneNote.app" --no-restart /Users/"${username}"
if [[ ${os_version} -ge 13 ]]; then
/usr/local/bin/dockutil --add "/System/Applications/System Settings.app" --no-restart /Users/"${username}"
else
/usr/local/bin/dockutil --add "/System/Applications/System Preferences.app" --no-restart /Users/"${username}"
fi
# Add Downloads
/usr/local/bin/dockutil --add '~/Downloads' --display folder --no-restart /Users/"${username}"
/usr/local/bin/dockutil --add '/Applications' --display folder --sort name /Users/"${username}"
sleep 5
sudo killall Dock