Skip to content

Instantly share code, notes, and snippets.

@smashism
Created February 14, 2022 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smashism/12e8c5ec9905e712027437151004e29d to your computer and use it in GitHub Desktop.
Save smashism/12e8c5ec9905e712027437151004e29d to your computer and use it in GitHub Desktop.
#!/bin/bash
###############################################################################
################################## VARIABLES ##################################
###############################################################################
dockutil=$(which dockutil)
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
uid=$(id -u "$currentUser")
# convenience function to run a command as the current user
# usage:
# runAsUser command arguments...
runAsUser() {
if [ "$currentUser" != "loginwindow" ]; then
launchctl asuser "$uid" sudo -u "$currentUser" "$@"
else
echo "no user logged in"
# uncomment the exit command
# to make the function exit with an error when no user is logged in
# exit 1
fi
}
###############################################################################
############################### APPLE DEFAULTS ################################
###############################################################################
runAsUser "$dockutil" --remove 'Launchpad' --no-restart
runAsUser "$dockutil" --remove 'Messages' --no-restart
runAsUser "$dockutil" --remove 'Launchpad' --no-restart
runAsUser "$dockutil" --remove 'Maps' --no-restart
runAsUser "$dockutil" --remove 'Photos' --no-restart
runAsUser "$dockutil" --remove 'FaceTime' --no-restart
runAsUser "$dockutil" --remove 'Contacts' --no-restart
runAsUser "$dockutil" --remove 'Reminders' --no-restart
runAsUser "$dockutil" --remove 'Notes' --no-restart
runAsUser "$dockutil" --remove 'TV' --no-restart
runAsUser "$dockutil" --remove 'Music' --no-restart
runAsUser "$dockutil" --remove 'Podcasts' --no-restart
runAsUser "$dockutil" --remove 'News' --no-restart
runAsUser "$dockutil" --remove 'Numbers' --no-restart
runAsUser "$dockutil" --remove 'Pages' --no-restart
###############################################################################
############################### JAMFY INSTALLS ################################
###############################################################################
if [ -d "/Applications/Microsoft Outlook.app" ] ; then
runAsUser "$dockutil" --add "/Applications/Microsoft Outlook.app" --no-restart
else
echo "Outlook not installed, skipping Dock placement"
fi
if [ -d "/Applications/Microsoft Word.app" ] ; then
runAsUser "$dockutil" --add "/Applications/Microsoft Word.app" --no-restart
else
echo "Word not installed, skipping Dock placement"
fi
if [ -d "/Applications/Microsoft Excel.app" ] ; then
runAsUser "$dockutil" --add "/Applications/Microsoft Excel.app" --no-restart
else
echo "Excel not installed, skipping Dock placement"
fi
if [ -d "/Applications/Adobe Acrobat Reader DC.app" ] ; then
runAsUser "$dockutil" --add "/Applications/Adobe Acrobat Reader DC.app" --no-restart
else
echo "Acrobat Reader DC not installed, skipping Dock placement"
fi
if [ -d "/Applications/Dropbox.app" ] ; then
runAsUser "$dockutil" --add "/Applications/Dropbox.app" --no-restart # dock icon doesn't seem to do anything shrug ¯\_(ツ)_/¯
else
echo "Dropbox not installed, skipping Dock placement"
fi
if [ -d "/Applications/zoom.us.app" ] ; then
runAsUser "$dockutil" --add "/Applications/zoom.us.app" --no-restart
else
echo "Zoom not installed, skipping Dock placement"
fi
if [ -d "/Applications/Slack.app" ] ; then
runAsUser "$dockutil" --add "/Applications/Slack.app" --no-restart
else
echo "Slack not installed, skipping Dock placement"
fi
if [ -d "/Applications/Google Chrome.app" ] ; then
runAsUser "$dockutil" --add "/Applications/Google Chrome.app" --position 1 --no-restart
else
echo "Google Chrome not installed, skipping Dock placement"
fi
runAsUser "$dockutil" --add "/Applications/Self Service.app" --before "Safari" --no-restart
runAsUser "$dockutil" --move "App Store" --position 99 --no-restart
runAsUser "$dockutil" --move "System Preferences" --position 100
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment