Posted on 06-21-2012 08:59 AM
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; }'
Solved! Go to Solution.
Posted on 06-21-2012 09:20 AM
Have a look at modifying /Library/Preferences/com.apple.dockfixup.plist so that the Apple items (e.g. AppStore) don't populate onto your dock. Also, look at the jamf binary. There's a modifyDock flag that has the option to remove that you're going to want to have a look at.
jamf help modifyDock
for more info.
Posted on 06-21-2012 09:13 AM
If there was ever a job for dockutil, this might be one. Check it out here:
https://jamfnation.jamfsoftware.com/viewProduct.html?id=203
Yes, it means deploying a binary to your managed systems, but that can be done silently ahead of time, if that works for you. Also, the executable still has to be called with something like a script at login. The dockutil binary is pretty well documented by the developer, so it should be pretty easy to add the commands to add/remove what you're looking to do.
Posted on 06-21-2012 09:20 AM
Have a look at modifying /Library/Preferences/com.apple.dockfixup.plist so that the Apple items (e.g. AppStore) don't populate onto your dock. Also, look at the jamf binary. There's a modifyDock flag that has the option to remove that you're going to want to have a look at.
jamf help modifyDock
for more info.
Posted on 06-21-2012 12:25 PM
In combination of editing com.apple.dockfixup.plist for adding icons such as office we used /System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/default.plist on removing default applications and it got us exactly what we need.
Thank you.
Posted on 10-30-2012 05:56 AM
@JaredNichols, were you able to get this to work for Mountain Lion? In my load script that runs before any user logs on, I replace the dockfixup.plist with my own that does not have the App store in there, but later in the script I run software updates and the App store re-appears on the dock. I know a simple solution would be to replace that file *after* running software updates, but I would like a solution that keeps the app store out of the dock even after an update, though I feel like that isn't going to happen.
Posted on 10-30-2012 06:18 AM
My solution historically (and continues to be in 10.8) a combination of a Dock plist in the user template and a custom dockfixup. I've never seen AppStore re-appear in the Dock.
Posted on 10-30-2012 06:26 AM
Hmm, that's exactly what I'm trying but for some reason it is not working. I am replacing the dock plist in the user template and the custom dockfixup before anyone logs onto the machine. Maybe I'm missing something. When/how are you replacing those files?
Posted on 10-30-2012 06:51 AM
There is another dock.plist in /System/Library/Core Services/Dock.app/Resources/
Or somewhere like that, that may be the issue.