Packaging Application Shortcuts for the Dock

msample
Contributor II

Running across the script for configuring the Dock, I added the direct paths in to the Applications folder but I'm still testing with the following script mods:

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

echo "$loggedInUser..."

# HARDCODED VALUES ARE SET HERE

# Applications Path, specify full path as in: /Applications/Safari.app
appPath="/Applications/Safari.app"
/usr/local/bin/dockutil --add '/Applications/Safari.app'
appPath="/Applications/Firefox.app"
/usr/local/bin/dockutil --add '/Applications/Firefox.app'
appPath="/Applications/Google Chrome.app"
/usr/local/bin/dockutil --add '/Applications/Google Chrome.app'
appPath="/Applications/Cisco AnyConnect Secure Mobility Client.app"
/usr/local/bin/dockutil --add '/Applications/Cisco AnyConnect Secure Mobility Client.app'
appPath="/Applications/Microsoft Office 2011/Microsoft Outlook.app"
/usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft Outlook.app'
appPath="/Applications/Microsoft Office 2011/Microsoft Word.app"
/usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft Word.app'
appPath="/Applications/Microsoft Office 2011/Microsoft Powerpoint.app"
/usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft Powerpoint.app'
appPath="/Applications/Microsoft Office 2011/Microsoft Excel.app"
/usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft Excel.app'
appPath="/Applications/Grab.app"
/usr/local/bin/dockutil --add '/Applications/Grab.app

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO "appPath"
if [ "$4" != "" ] && [ "$appPath" == "" ];then appPath=$4
fi

##
# Error if variable appPath is empty
##
if [ "$appPath" == "" ]; then echo "Error: No value was specified for the appPath variable..." exit 1
fi

###
# Add the App as given at $appPath
###

echo "Will add "$appPath"..."

sudo -u "$loggedInUser" /usr/local/bin/dockutil --add "$appPath" /Users/"$loggedInUser"

echo "Added "$appPath" to /Users/"$loggedInUser"..."

The first test found the associated apps but didn't populate the Dock. Do I need to run a script to kill the dock first? Before attaching this script, what's the best practice creating the dock?

3 REPLIES 3

hkabik
Valued Contributor

You may need to kill cfprefsd before the dock restarts for the changes to take place.

msample
Contributor II

Thanks, Hanan...I do have a script that I can use to perform that tasks. Create a policy and attach the Kill cfprefsd script to it?

hkabik
Valued Contributor

I usually just attach a Find/Kill for process cfprefsd to the policy when I create it, that generally does the trick for me.