Re: Problem Adding an Application to the Dock
Re: Problem Adding an Application to the Dock
- Subject: Re: Problem Adding an Application to the Dock
- From: deivy petrescu <email@hidden>
- Date: Sat, 21 Jun 2008 11:53:04 -0400
On Jun 17, 2008, at 12:10, Dave wrote:
Hi All,
I use the following handler to add a file to the dock. This works
really well except if the file is already in the dock, it add it
again! I'm having trouble figuring out the shell command to remove
the file from the dock.
Any help greatly appreciated.
Thanks a lot
All the Best
Dave
------------------------------------------------------------------------
--
-- AddFileToDock
--
------------------------------------------------------------------------
on AddFileToDock(theFilePathNameString)
--display dialog theFilePathNameString
set myShellCommandString to "defaults write com.apple.dock
persistent-apps -array-add '<dict><key>tile-data</
key><dict><key>file-data</key><dict><key>_CFURLString</key><string>"
& theFilePathNameString & "</string><key>_CFURLStringType</
key><integer>0</integer></dict></dict></dict>'"
do shell script myShellCommandString
do shell script "sh -c \"killall Dock\""
end AddFileToDock _______________________________________________
Hi there Dave,
This should get you started in how to avoid adding existing items to
the dock
<script>
set applctn to "Maple"
try
set l to do shell script "defaults read com.apple.dock persistent-
apps | grep " & applctn
display dialog "The application " & applctn & " is in the persistent
dock"
on error
display dialog "The application " & applctn & " is *not* in the
persistent dock"
end try
<script>
To remove an item try
<script>
set applctn to "Maple"
try
set l to do shell script "defaults delete com.apple.dock persistent-
apps " & applctn
display dialog "The application " & applctn & " was removed from the
persistent dock"
on error
display dialog "The application " & applctn & " is *not* in the
persistent dock"
end try
</script>
You can also try man defaults in your terminal or applescript.
Deivy
_______________________________________________
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