I've searched for a solution as well as tried to create my own and I'm running out of ideas.
I need to remove some icons from the dock as well as add MS Office 2012 icons. Using casper Dock policy once per user at logon doesn't work as it removed Downloads and Documents (works fine when using every15 trigger, but that's not a solution considering the dock might change 15 minutes from login time). I tried using applescript, but it fails at logon because profile is not completed yet. I tried using sh script to add the applescript to the login items. It works when testing manually, however when I add sh script to login policy it never adds it to login items to be executed after user has completely logged in.
Here are the scripts I have:
try
do shell script "Killall Dock"
end try
tell application "System Events"
set dockPlistFile to property list file "~/Library/Preferences/com.apple.dock.plist"
tell dockPlistFile
tell property list item "persistent-apps"
set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "Mail")
set its value to appTileItems
set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "Safari")
set its value to appTileItems
set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "FaceTime")
set its value to appTileItems
set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "Address Book")
set its value to appTileItems
set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "iCal")
set its value to appTileItems
set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "iTunes")
set its value to appTileItems
set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "Photo Booth")
set its value to appTileItems
set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "System Preferences")
set its value to appTileItems
end tell
end tell
end tell
try
tell application "Dock" to quit
end try
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Google Chrome.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Office 2011/Microsoft Word.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Office 2011/Microsoft Excel.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Office 2011/Microsoft Powerpoint.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Office 2011/Microsoft Outlook.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"
try
do shell script "Killall Dock"
end try
tell application "System Events"
get the name of every login item
if login item "FixDock" exists then
delete login item "FixDock"
end if
end tell
That removes dock items and adds office icons.
Here's script to add item to login items list:
#!/bin/sh
defaults write loginwindow AutoLaunchedApplicationDictionary -array-add '{ "Path"="/Library/temp/FixDock.app"; "Hide" = 0; }'