Skip to content

Instantly share code, notes, and snippets.

@calum-github
Created January 11, 2016 23:17
Show Gist options
  • Save calum-github/b97d641bda86b51c2fc0 to your computer and use it in GitHub Desktop.
Save calum-github/b97d641bda86b51c2fc0 to your computer and use it in GitHub Desktop.
dockutil script
#!/bin/bash
################################################################################
# Author: Calum Hunter #
# Date: 12/01/2016 #
# Version: 1.91 #
# Purpose: Default dock settings for user accounts #
# Configured via Dockutil #
# This should be run as a initial login script via LauchAgent #
################################################################################
#---Variables and such---#
script_version="1.91"
user_id=`id -u`
user_name=`id -un $user_id`
home_dir="/Users/$user_name"
dock_setup_done="$home_dir/.docksetupdone"
log_file="$home_dir/Library/Logs/dock_setup.log"
os_vers=`sw_vers -productVersion | awk -F "." '{print $2}'`
#---Redirect output to log---#
exec >> $log_file 2>&1
# Check for Adobe CC Version
if [ -e /Applications/Adobe\ Photoshop\ CC\ 2015/Adobe\ Photoshop\ CC\ 2015.app ]; then
adobe_vers="2015"
elif [ -e /Applications/Adobe\ Photoshop\ CC/Adobe\ Photoshop\ CC.app ]; then
adobe_vers="2014"
fi
# Check for Office Version
if [ -e /Applications/Microsoft\ Office\ 2011/Microsoft\ Word.app ]; then
office_vers="2011"
elif [ -e /Applications/Microsoft\ Word.app ]; then
office_vers="2016"
fi
# Check for iLife apps
if [ -e /Applications/iMovie.app ]; then
ilife="true"
fi
# Check for iWork apps
if [ -e /Applications/Numbers.app ]; then
iwork="true"
fi
# Check for Google Chrome
if [ -e /Applications/Google\ Chrome.app ]; then
chrome="true"
fi
#---Functions---#
adobe_cc_2014(){
echo `date "+%a %b %d %H:%M:%S"` " - Adding Adobe CC 2014 items to Dock..."
/usr/local/bin/dockutil --add '/Applications/Adobe Acrobat XI Pro/Adobe Acrobat Pro.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe After Effects CC 2014/Adobe After Effects CC 2014.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Audition CC 2014/Adobe Audition CC 2014.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Dreamweaver CC 2014.1/Adobe Dreamweaver CC 2014.1.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Edge Animate CC 2014.1/Adobe Edge Animate CC 2014.1.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Fireworks CS6/Adobe Fireworks CS6.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Flash Builder 4.7/Adobe Flash Builder 4.7.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Flash CC 2014/Adobe Flash CC 2014.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Illustrator CC 2014/Adobe Illustrator.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe InDesign CC 2014/Adobe InDesign CC 2014.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Muse CC 2014/Adobe Muse CC 2014.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Photoshop CC 2014/Adobe Photoshop CC 2014.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Prelude CC 2014/Adobe Prelude CC 2014.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Premiere Elements 13/Adobe Premiere Elements 13.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Premiere Pro CC 2014/Adobe Premiere Pro CC 2014.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe SpeedGrade CC 2014/Adobe SpeedGrade CC 2014.app' --no-restart
}
iwork_apps(){
echo `date "+%a %b %d %H:%M:%S"` " - Adding iWork items to Dock..."
/usr/local/bin/dockutil --add '/Applications/Numbers.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Pages.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Keynote.app' --no-restart
}
ilife_apps(){
echo `date "+%a %b %d %H:%M:%S"` " - Adding iLife items to Dock..."
/usr/local/bin/dockutil --add '/Applications/iMovie.app' --no-restart
}
google_chrome(){
echo `date "+%a %b %d %H:%M:%S"` " - Adding Google Chrome to Dock..."
/usr/local/bin/dockutil --add '/Applications/Google Chrome.app' --no-restart
}
adobe_cc_2015(){
echo `date "+%a %b %d %H:%M:%S"` " - Adding Adobe CC 2015 items to Dock..."
/usr/local/bin/dockutil --add '/Applications/Adobe Acrobat DC/Adobe Acrobat.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe After Effects CC 2015/Adobe After Effects CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Audition CC 2015/Adobe Audition CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Dreamweaver CC 2015/Adobe Dreamweaver CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Edge Animate CC 2015/Adobe Edge Animate CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Fireworks CS6/Adobe Fireworks CS6.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Flash Builder 4.7/Adobe Flash Builder 4.7.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Flash CC 2015/Adobe Flash CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Illustrator CC 2015/Adobe Illustrator.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe InDesign CC 2015/Adobe InDesign CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Muse CC 2015/Adobe Muse CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Photoshop CC 2015/Adobe Photoshop CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Prelude CC 2015/Adobe Prelude CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Premiere Elements 13/Adobe Premiere Elements 13.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Premiere Pro CC 2015/Adobe Premiere Pro CC 2015.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe SpeedGrade CC 2015/Adobe SpeedGrade CC 2015.app' --no-restart
}
office_2011(){
echo `date "+%a %b %d %H:%M:%S"` " - Adding Office 2011 Dock items..."
/usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft Word.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft Excel.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft PowerPoint.app' --no-restart
}
office_2016(){
echo `date "+%a %b %d %H:%M:%S"` " - Adding Office 2016 Dock items..."
/usr/local/bin/dockutil --add '/Applications/Microsoft Word.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Microsoft Excel.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Microsoft PowerPoint.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Microsoft OneNote.app' --no-restart
}
initial_dock_setup(){ # Remove the dock items we don't want
echo "*************************************************************************"
echo `date "+%a %b %d %H:%M:%S"` " - Dock setup beginning v${script_version}"
echo `date "+%a %b %d %H:%M:%S"` " - User: $user_name"
echo `date "+%a %b %d %H:%M:%S"` " - User ID: $user_id"
echo `date "+%a %b %d %H:%M:%S"` " - Home Dir: $home_dir"
echo `date "+%a %b %d %H:%M:%S"` " - OS Vers: 10.${os_vers}"
echo `date "+%a %b %d %H:%M:%S"` " - Office Version: Office $office_vers"
echo `date "+%a %b %d %H:%M:%S"` " - Adobe CC Version: Adobe CC $adobe_vers"
echo `date "+%a %b %d %H:%M:%S"` " - Adobe CC Version: Adobe CC $adobe_vers"
echo `date "+%a %b %d %H:%M:%S"` " - Waiting for presence of dock plist..."
while [ ! -f ~/Library/Preferences/com.apple.dock.plist ]; do
sleep 1 # We sleep 1 seconds here so we don't totally kill the cpu usage
done
sleep 2 # We sleep 2 seconds here so that Apple can set the dock corectly before we modify it
echo `date "+%a %b %d %H:%M:%S"` " - Removing all Dock items..."
/usr/local/bin/dockutil --remove all
sleep 1
echo `date "+%a %b %d %H:%M:%S"` " - Adding new Dock Items..."
/usr/local/bin/dockutil --add '/Applications/Network Connector.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Safari.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Firefox.app' --no-restart
if [ $chrome = "true" ]; then # If Chrome is installed we should add it
google_chrome
fi
# Check to see which version of Adobe CC apps we should add to the Dock
if [ $adobe_vers = "2014" ]; then
adobe_cc_2014
elif [ $adobe_vers = "2015" ]; then
adobe_cc_2015
fi
# Check to see wich version of office we should add to the Dock
if [ $office_vers = "2011" ]; then
office_2011
elif [ $office_vers = "2016" ]; then
office_2016
fi
# Add iLife
if [ $ilife = "true" ]; then
ilife_apps
fi
# Add iWork
if [ $iwork = "true" ]; then
iwork_apps
fi
# Add photos.app if we are greater than 10.9 ie 10.10 and 10.11
if [ $os_vers -gt "9" ]; then
/usr/local/bin/dockutil --add '/Applications/Photos.app' --no-restart
fi
# Add our standard OS X Apps
/usr/local/bin/dockutil --add '/Applications/Photo Booth.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/iBooks.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/iTunes.app' # We restart here before we add folders, its more reliable for some reason
# Add our standard folders, home dir and downloads
/usr/local/bin/dockutil --add "$home_dir" --view list --display folder --no-restart
/usr/local/bin/dockutil --add "$home_dir/Downloads" --view list --display folder
echo `date "+%a %b %d %H:%M:%S"` " - Dock setup complete!"
echo "*************************************************************************"
touch $dock_setup_done
}
#---Script Actions---#
# Don't run for the Admin user
if [ $user_name = "admin" ]; then
exit 0
fi
if [ ! -f $dock_setup_done ]; then # Check if the dock setup script has been run before
initial_dock_setup
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment