Re: Remove icon from dock after adding it
Re: Remove icon from dock after adding it
- Subject: Re: Remove icon from dock after adding it
- From: Chris Page <email@hidden>
- Date: Fri, 24 Jul 2009 20:07:25 -0700
On Jul 24, 2009, at 6:36 AM, Luther Fuller wrote: On Jul 24, 2009, at 1:05 AM, Chris Page wrote: On Jul 23, 2009, at 10:21 AM, Laine Lee wrote: killall Dock
Two notes:
1. Don't use "killall Dock". That unilaterally kills the Dock process without giving Dock a chance to commit any unsaved changes. Instead, send the Dock a "quit" event.
2. Before you modify the preferences, quit the Dock so it will commit any unsaved changes. Then modify the preferences, then quit the Dock again to ensure it sees the new preferences—because it automatically relaunches and may do so before your preferences changes are committed.
I currently use this code snippet to add an item to the Dock ...
set prefsFile to (((path to preferences from user domain) as text) & "com.apple.dock.plist") as alias tell application "System Events" set dockPath to (prefsFile as text) set dockRec to (value of property list file dockPath) set |persistent-others| of dockRec to ((|persistent-others| of dockRec) & {newMenuFolderItem}) set (value of property list file dockPath) to dockRec end tell tell application "Dock" to quit
Are you recommending that I also quit the Dock before this snippet? And if I do that, do I really need to quit after?
Yes, and yes. That's specifically the point of my message. How long is the Dock dormant after the quit command?
You can't predict how long it will remain dormant. It may relaunch before you even get the reply to the first quit event. Not only does it depend on numerous pieces of software that may change in the future, it depends on the speed of your computer and hard drive, and how busy they are at the time you tell Dock to quit. This is why you must quit it after modifying the preferences; otherwise, there's a race condition and your script isn't guaranteed to work in all cases, especially as computers get faster.
|
_______________________________________________
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