Hello all,
I've been using Dockutil to set the Dock for our elementary students and in it's current form it's based on user (because we had grade level login accounts, which we've since gotten ride of).
I need to change our script so that it applies Dock settings based on the user's group (for example: class of 2037, class of 2036, class of 2035). I could break my head trying to figure it out but I'm hoping someone on here might know exactly what to do. Here's the current script:
#!/bin/bash
#We need to wait for the dock to actually start
until [[ $(pgrep Dock) ]]; do
wait
done
#Get the current logged in user that we'll be modifying
if [ ! -z "$3" ]; then
user=$3
else
user=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
fi
#Set variables
du="/usr/local/bin/dockutil"
userHome="/Users/$user"
networkHome="smb://server.com/Students$/$user"
#Function for applying dock configuration
createBaseDock()
{
#Remove all items for logged in user
$du --remove all --no-restart $userHome
#Adding base items to the dock
$du --add '/Applications/Google Chrome.app' --position 1 --no-restart $userHome
$du --add '/Applications/Safari.app' --position 2 --no-restart $userHome
$du --add '/Applications/Comic Life 3.app' --position 3 --no-restart $userHome
$du --add '/Applications/The Print Shop 4.app' --position 4 --no-restart $userHome
$du --add '/Applications/KID PIX.app' --position 5 --no-restart $userHome
}
#Function for finishing base dock
finishBaseDock()
{
#Add local downloads
$du --add '~/Downloads' --section others --position last --no-restart $userHome
killall Dock
}
createBaseDock
case $user in
p|k) echo "p or k found";;
1) echo "1 found"
$du --add '/System/Applications/Photo Booth.app' --position 6 --no-restart $userHome;;
2) echo "2 found"
$du --add '/System/Applications/Photo Booth.app' --position 6 --no-restart $userHome;;
3) echo "3 found"
$du --add '/System/Applications/Photo Booth.app' --position 6 --no-restart $userHome
$du --add '/Applications/Adobe Photoshop 2020/Adobe Photoshop 2020.app' --position 7 --no-restart $userHome;;
esac
finishBaseDock
exit 0