Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Remove icon from dock after adding it
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove icon from dock after adding it



On Jul 23, 2009, at 11:18 AM, Laine Lee wrote:
I added an icon to the dock by editing its plist with an Applescript:

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/Custom Tool.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"

How might I alter the defaults command used in that script to reverse the action (remove the icon from the dock) leaving the dock in its previous state? Can I use “defaults find” to find the key then use “defaults delete to delete it? I’ve read the manual for defaults and I still need help. Thanks.

In my experience using System Events is a lot easier than using 'defaults'. To remove a Dock item you have to find and delete the item of the list/array 'persistent-others' that refers to the Dock tile. A picture is worth a thousand words at this point, so ...


Obtained using Property List Editor. If you wanted to remove the Dock item named "Actions", you would remove item 2 of the list/array 'persistent-others'. Of course, you have to know the structure of the items of 'persistent-others' in order to search for "Actions".

set prefsFile to (((path to preferences from user domain) as text) & "com.apple.dock.plist") as alias
tell application "System Events"
prefsFile as text
set poArray to (value of property list item "persistent-others" of property list file the result)
repeat with i from 1 to (count items of poArray)
set poItem to item i of poArray
set tileDataRec to |tile-data| of poItem
set tileName to |file-label| of tileDataRec
display dialog tileName
end repeat
end tell

I just ran this code ... and it worked!

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Remove icon from dock after adding it (From: Laine Lee <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.