Hello,
I have a script that edits the Finder plist (com.apple.finder.plist) and changes it to fit our needs. It runs perfectly well when it is a .command and executed by double clicking on it, but it does not fully execute when put inside a package or when set as a login policy (in either .pkg, .command, or .sh formats). It also doesn't execute correctly when put on the desktop or other location and called via "sudo sh /path-to-file" in Terminal.
The only part that works when triggered via JAMF or a .pkg is the part where it adds items to the Favorites sidebar in Finder. The rest of it does not work.
Our intent is to have this run once per user at logon, which will set up a default Finder experience, but allow the user to change it as they see fit, so Configuration Profiles which will make the changes static don't fit our needs.
Any help would be appreciated.
#!/bin/bash
#Add Movies, Music, Pictures, <username>, to Finder Favorites sidebar.
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
if [ -e /usr/bin/sfltool ]
then
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser/Movies && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser/Music && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser/Pictures && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser && sleep 2
touch /Users/$loggedInUser/.sidebarshortcuts
fi
#Turns on show Hard Disks, External disks, CDs, DVDs, and iPads, and Connected Servers
/usr/bin/defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true;
/usr/bin/defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true;
/usr/bin/defaults write com.apple.finder ShowMountedServersOnDesktop -bool true;
/usr/bin/defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true;
#Shows Status Bar
/usr/bin/defaults write com.apple.finder ShowStatusBar -bool true;
#Shows Tab View
/usr/bin/defaults write com.apple.finder ShowTabView -bool true;
#Shows Path Bar
/usr/bin/defaults write com.apple.finder ShowPathbar -bool true;
#Changes Finder to List View
#Four-letter codes for the other view modes: 'icnv', 'clmv', 'Flwv'
/usr/bin/defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
#New Finder windows now opens in /Users/<username>
/usr/bin/defaults write com.apple.finder NewWindowTarget -string "PfHm"
#Restarts cfprefsd and Finder
killAll cfprefsd
killAll Finder
echo "Finder Preferences set"
exit 0