An open community 
of Macintosh users,
for Macintosh users.

FineTunedMac Dashboard widget now available! Download Here

Previous Thread
Next Thread
Print Thread
Page 1 of 2 1 2
undo poof out of dock?
#8107 02/01/10 05:48 PM
Joined: Aug 2009
OP Offline

Joined: Aug 2009

More than once I've been working on a machine and accidentally poofed something from the dock when trying to open an app from there.

Is there any way to undo this? or to find out what you just poofed?


I work for the Department of Redundancy Department
Re: undo poof out of dock?
Virtual1 #8108 02/01/10 07:32 PM
Joined: Sep 2009
Offline

Joined: Sep 2009
No undo.

You'd need a (backup) dock.plist from before the move to compare to the current:

defaults read com.apple.dock |sed '/^ *"_CFURLString" = /!d;s///'

If this happens a lot, maybe the first thing to do when working on a machine is to backup the dock.plist (and whatever else necessary). Then when you're finished, just copy 'em back.
wink

--

Although, there seems to be some sort of (SQL?) database cache file at ~/Library/Preferences/com.apple.dock.db -- but i don't know how to "decode" it. Yikes, i just ran strings on it...

strings ~/Library/Preferences/com.apple.dock.db

...and i couldn't believe the junk Apple has squirreled away in there!!!
(try it and see).

Last edited by Hal Itosis; 02/01/10 07:39 PM.
Re: undo poof out of dock?
Hal Itosis #8116 02/02/10 04:36 PM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
The specific problem I'm having is when working with someone else's machine. Sometimes if it's behaving erratically or laggy it's easy to accidentally drag a click in the dock and poof something when trying to work with desktop icons that users have placed just above (or partly under) their dock.

Of course that often means I didn't catch what I managed to poof. So (A) I don't know what it was and (B) I'm not going to be having a backup of the plist....


I work for the Department of Redundancy Department
Re: undo poof out of dock?
Virtual1 #8118 02/02/10 05:37 PM
Joined: Sep 2009
Offline

Joined: Sep 2009
Originally Posted By: Virtual1
(A) I don't know what it was and
(B) I'm not going to be having a backup of the plist.

If this happens a lot, maybe the first thing to do when working on a machine is to backup the dock.plist (and whatever else necessary). Then when you're finished, just copy 'em back.

(What else can i say? -- i don't think any other choice exists -- visit your optometrist perhaps?).

EDIT: take a screenshot maybe (command-shift-3),

Last edited by Hal Itosis; 02/02/10 05:46 PM.
Re: undo poof out of dock?
Hal Itosis #8126 02/03/10 12:03 AM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
it doesn't happen enough to warrant additional preparations, I was just hoping there was something I could do on the rare now and then that it happens, besides cuss and mumble about having no idea what just went POOF


I work for the Department of Redundancy Department
Re: undo poof out of dock?
Virtual1 #8128 02/03/10 12:16 AM
Joined: Aug 2009
Offline

Joined: Aug 2009
there definitely should be a way to undo that.


MacBook 2.4 Ghz · 4 Gb ram · 10.7.5
stuff I'm interested in
iPhone 4s 7.0.2
Re: undo poof out of dock?
roger #8158 02/03/10 11:57 PM
Joined: Aug 2009
Likes: 16
Moderator
Online
Moderator

Joined: Aug 2009
Likes: 16
There is. It is called Time Machine.


If we knew what it was we were doing, it wouldn't be called research, would it?

— Albert Einstein
Re: undo poof out of dock?
joemikeb #8166 02/04/10 03:50 AM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
I didn't know time machine could restore missing dock items. How do you do that?


I work for the Department of Redundancy Department
Re: undo poof out of dock?
Virtual1 #8167 02/04/10 04:29 AM
Joined: Aug 2009
Offline

Joined: Aug 2009
You could restore the plist file at ~/Library/Preferences/com.apple.dock.plist .


MicroMat Inc
Makers of TechTool
Re: undo poof out of dock?
MicroMatTech3 #8168 02/04/10 04:38 AM
Joined: Sep 2009
Offline

Joined: Sep 2009
Third Base!

Re: undo poof out of dock?
joemikeb #8171 02/04/10 01:16 PM
Joined: Aug 2009
Likes: 3
Moderator
Offline
Moderator

Joined: Aug 2009
Likes: 3

Originally Posted By: Virtual1
it doesn't happen enough to warrant additional preparations, I was just hoping there was something I could do on the rare now and then that it happens, besides cuss and mumble about having no idea what just went POOF

Since Virtual isn't sufficiently motivated by the problem to back up the specific file which holds the desired information, he may not want to bother locating and navigating through a Time Machine backup and restoring the file in question, assuming a Time Machine backup is available.

Plus, in my experimenting (OS X 10.5.8), restoring a saved copy of com.apple.dock.plist, then running killall Dock, failed to restore the poofed application to the relaunched Dock. (Same with com.apple.dock.db.) So, if a logout/login or restart are required, that makes restoring a backed-up plist even more time-consuming.

How about scripting the production of a simple list of the Dock's contents, requiring just a double-click at the beginning of a session? A comparison of the list, in the rare instance it was required, with the extant Dock should make it easy to identify the poofee.

Parsing the XML and extracting the item names shouldn't be too tough; I might even try it myself.



dkmarsh—member, FineTunedMac Co-op Board of Directors
Re: undo poof out of dock?
dkmarsh #8172 02/04/10 01:49 PM
Joined: Aug 2009
Likes: 1
Moderator
Offline
Moderator

Joined: Aug 2009
Likes: 1
Originally Posted By: dkmarsh
Parsing the XML and extracting the item names shouldn't be too tough; I might even try it myself.

Ahh! I spy yet another great little FTM utility! tongue


alternaut moderator
Re: undo poof out of dock?
dkmarsh #8177 02/04/10 05:58 PM
Joined: Sep 2009
Offline

Joined: Sep 2009
Originally Posted By: dkmarsh
Plus, in my experimenting (OS X 10.5.8), restoring a saved copy of com.apple.dock.plist, then running killall Dock, failed to restore the poofed application to the relaunched Dock. (Same with com.apple.dock.db.) So, if a logout/login or restart are required, that makes restoring a backed-up plist even more time-consuming.

Perhaps if the script would quit Finder (quit, not relaunch), delay/sleep for a second (or 2), write the plist, and then resurrect Finder, maybe. . .

Re: undo poof out of dock?
Hal Itosis #8180 02/04/10 11:08 PM
Joined: Aug 2009
Offline

Joined: Aug 2009
The following worked on my MacBook Pro Core 2 Duo running Mac OS X 10.6.2. Before I began, I noted where Disk Utility was in my Dock.

Before subjecting the Dock to unintentional poofing, make backups of the following files, by selecting them in the Finder and typing Command D:

1. ~/Library/Preferences/com.apple.dock.plist

2. ~/Library/Preferences/com.apple.dock.db

We now have two new files:

~/Library/Preferences/com.apple.dock copy.plist

~/Library/Preferences/com.apple.dock.db copy

Remove Disk Utility from the Dock. Poof!

Delete:

~/Library/Preferences/com.apple.dock.plist

~/Library/Preferences/com.apple.dock.db

Rename:

~/Library/Preferences/com.apple.dock copy.plist to ~/Library/Preferences/com.apple.dock.plist

~/Library/Preferences/com.apple.dock.db copy to ~/Library/Preferences/com.apple.dock.db

Launch Activity Monitor, located in /Applications/Utilities. Force the process named Dock to quit. When the Dock relaunches automatically after a few seconds of sheer Docklessness, note that Disk Utility is right where it belongs in the Dock.


MicroMat Inc
Makers of TechTool
Re: undo poof out of dock?
MicroMatTech3 #8183 02/05/10 12:42 AM
Joined: Aug 2009
Likes: 3
Moderator
Offline
Moderator

Joined: Aug 2009
Likes: 3

Excellent! Thanks for the solution to the restore issue.

In Virtual1's scenario (working on someone else's Mac), this approach requires backing up the specified files, then, in the vast majority of cases—in which no poofing occurs—deleting them at the conclusion of the session (following the Boy Scout credo of leaving things as clean as you found them).




dkmarsh—member, FineTunedMac Co-op Board of Directors
Re: undo poof out of dock?
dkmarsh #8185 02/05/10 01:07 AM
Joined: Aug 2009
Offline

Joined: Aug 2009
dkmarsh,

I had thought that the idea of “leaving only footprints” originated with Colin Fletcher, but this topic may prove more difficult to research than the best method of restoring a Dock:

http://www.clubtread.org/etiquett.php

I never made it to Boy Scout. I was a Cub Scout, and had to endure den meetings in which the den mother’s son was allowed to pester me with his deformed fingernail. We made one interesting trip to a place of geological interest, and that was the end for me. I still think Scouting is a great idea, and wish I could find a royal blue cotton shirt that reminds me of my Cub Scout shirt. I had a reference to the shirt in one of my databases, and of course, I cannot find it now. I guess I am unprepared.


MicroMat Inc
Makers of TechTool
Re: undo poof out of dock?
MicroMatTech3 #8196 02/05/10 07:48 PM
Joined: Aug 2009
Offline

Joined: Aug 2009
"Before subjecting the Dock to unintentional poofing,"

"honey, I think I'm going to poof!"

cool

I'm thinking of a "normal" Mac user, and that this must happen not unfrequently. a little Finder Undo would be handy. all this plist stuff is great, but next we'll be bringing out Terminal...


MacBook 2.4 Ghz · 4 Gb ram · 10.7.5
stuff I'm interested in
iPhone 4s 7.0.2
Re: undo poof out of dock?
roger #8198 02/05/10 09:53 PM
Joined: Sep 2009
Offline

Joined: Sep 2009
Originally Posted By: roger
I'm thinking of a "normal" Mac user, and that this must happen not unfrequently. a little Finder Undo would be handy. all this plist stuff is great, but next we'll be bringing out Terminal...

Actually, the whole thing would be best wrapped in an AppleScript applet [which itself could make Unix-type calls, if necessary (e.g., not that it's needed, but if there was something that AppleScript doesn't do easily... such as defaults read perhaps, then it could be achieved via the do shell script syntax).]

So the user would run it, and a dialog would ask if we're saving a backup or restoring a poofed dock... and then it would do all the copying, process killing, etc., etc.

Anyway, it could all be reduced to double-clicking an app and then clicking one button in a dialog. The main trick will be remembering to run it early on, to save the backup plist in the first place.

EDIT: At this point i'm still not convinced that "com.apple.dock.db" is anything crucial. From what i've seen of it so far, i'd almost think we'd be doing the user a favor by *erasing* it [and letting the OS build a brand new one (smaller and cleaner) from our preserved plist.]

EDIT 2: BTW, there is also another cache for the dock, but it seems more devoted to icon data (for faster drawing i guess -- probably handy for the magnification feature):

ls -lh /var/folders/*/*/-Caches-/com.apple.dock.*

Last edited by Hal Itosis; 02/05/10 10:14 PM.
Re: undo poof out of dock?
Hal Itosis #8203 02/06/10 05:02 AM
Joined: Aug 2009
Likes: 3
Moderator
Offline
Moderator

Joined: Aug 2009
Likes: 3

I'm sure it would be easier if I knew how to manipulate text from the command line, but this AppleScript script works on my machine (OS X 10.5.8):

set itemList to {}
set theList to do shell script "defaults read com.apple.dock | grep 'file-label' | cut -c 31-"
set AppleScript's text item delimiters to return
set itemList to text items of theList
set endList to {}
set AppleScript's text item delimiters to " "
repeat with n from 1 to count of itemList
set j to item n of itemList as text
set end of endList to (words of j as text)
end repeat
set AppleScript's text item delimiters to return
display dialog endList as text
set AppleScript's text item delimiters to ""

(Note that any non-'word' characters will be left behind; on my machine, for instance, ViaCAD 2D/3D is displayed as ViaCAD 2D 3D.)

Figuring out how to save this information for potential use and discard it if it turns out not to be needed is left as an exercise for the reader. wink



dkmarsh—member, FineTunedMac Co-op Board of Directors
Re: undo poof out of dock?
dkmarsh #8204 02/06/10 05:42 AM
Joined: Sep 2009
Offline

Joined: Sep 2009
Heck, why not just copy the whole file: do shell script "cp -fp ~/Library/Preferences/com.apple.dock.plist /tmp/" ... for the backup part, and do the reverse for restore: do shell script "cp -fp /tmp/com.apple.dock.plist ~/Library/Preferences/" [there are basic AppleScript equivalents that could do as well without a "do shell script" statement.]

All that's needed is to display dialog asking whether we're doing a backup or a restore. If it's a restore, we need to kill the running dock (or maybe quite Finder with: ignoring application responses tell application "Finder" to quit -- do the reverse copy from /tmp to prefs/ -- and resurrect Finder with: tell application "Finder" to activate ). Some "delay 2" statements may need to be sprinkled strategically within that block... but that's about 90% of the task there (i think).

edit: i guess the restore routine should check that a backup file exists... else tell the user: "too late dude, no backup found... would you like to backup now instead?"

Last edited by Hal Itosis; 02/06/10 05:51 AM.
Re: undo poof out of dock?
Hal Itosis #8210 02/06/10 02:41 PM
Joined: Aug 2009
Offline

Joined: Aug 2009
well, I consider myself a bit more than an average mac-user, but I rarely use Applescript, and I would guess that most mac-users don't either.

having to know ahead of time that I might accidentally poof something from the Dock so I'd better run a backup script? every time I go to the Dock?

Finder - Edit - Undo Delete from Dock


MacBook 2.4 Ghz · 4 Gb ram · 10.7.5
stuff I'm interested in
iPhone 4s 7.0.2
Re: undo poof out of dock?
roger #8213 02/06/10 03:20 PM
Joined: Aug 2009
Likes: 1
Moderator
Offline
Moderator

Joined: Aug 2009
Likes: 1
Originally Posted By: roger
Finder - Edit - Undo Delete from Dock

Oops: Can't Undo shocked


alternaut moderator
Re: undo poof out of dock?
roger #8214 02/06/10 03:23 PM
Joined: Aug 2009
Likes: 1
Online

Joined: Aug 2009
Likes: 1
Or, borrowing from AutoDesk, a simple Oops command which "undoes" whatever you did last would be great. In AutoCad, multiple Oops commands continue to undo the previous action until you get to the last saved state of the file. But, a simple return will allow you to continue to Oops some more.

Re: undo poof out of dock?
alternaut #8217 02/06/10 03:48 PM
Joined: Aug 2009
Offline

Joined: Aug 2009
Originally Posted By: alternaut
Originally Posted By: roger
Finder - Edit - Undo Delete from Dock

Oops: Can't Undo shocked


yeah, just seems strange that OSX can't keep track of an alias.


MacBook 2.4 Ghz · 4 Gb ram · 10.7.5
stuff I'm interested in
iPhone 4s 7.0.2
Re: undo poof out of dock?
roger #8220 02/06/10 05:03 PM
Joined: Sep 2009
Offline

Joined: Sep 2009
Originally Posted By: roger
well, I consider myself a bit more than an average mac-user, but I rarely use Applescript, and I would guess that most mac-users don't either.

having to know ahead of time that I might accidentally poof something from the Dock so I'd better run a backup script?

Finder - Edit - Undo Delete from Dock

That's not what this is about. I mean, i agree with you... it "should" be there. But it's not. So, some workaround is needed.

[the other thing is... this wasn't a general issue about one user and their Mac. It was originally about Virtual1, who works on a bunch of Macs every day, that don't belong to him.]

To summarize: we agree that a "Undo" should be there... and, i think we also agree that it's not there.

So, i guess the remaining question is: does a script solution interest anyone? grin


Originally Posted By: roger
every time I go to the Dock?

No... that would only be needed for V1, who works on a bunch of *different* Macs every day, that don't belong to him. [and even there, he would just backup once... as soon as he logged in.]

A more general solution [for users operating their own machines] would have the "backup" part automated (perhaps running every time the dock plist gets modified... or maybe just once an hour). In that scenario, all we would need is to run the script and choose 'Restore'.

Last edited by Hal Itosis; 02/06/10 05:09 PM.
Page 1 of 2 1 2

Moderated by  alternaut, dkmarsh, joemikeb 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.4.33 Page Time: 0.065s Queries: 65 (0.052s) Memory: 0.7169 MB (Peak: 0.9047 MB) Data Comp: Zlib Server Time: 2024-03-28 15:03:48 UTC
Valid HTML 5 and Valid CSS