An open community 
of Macintosh users,
for Macintosh users.

FineTunedMac Dashboard widget now available! Download Here

Page 1 of 2 1 2 >
Topic Options
#8107 - 02/01/10 09:48 AM undo poof out of dock?
Virtual1 Offline


Registered: 08/04/09
Loc: Iowa

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

Top
#8108 - 02/01/10 11:32 AM Re: undo poof out of dock? [Re: Virtual1]
Hal Itosis Offline


Registered: 09/03/09
Loc: 10.6.8 (build 10K549)
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).


Edited by Hal Itosis (02/01/10 11:39 AM)

Top
#8116 - 02/02/10 08:36 AM Re: undo poof out of dock? [Re: Hal Itosis]
Virtual1 Offline


Registered: 08/04/09
Loc: Iowa
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

Top
#8118 - 02/02/10 09:37 AM Re: undo poof out of dock? [Re: Virtual1]
Hal Itosis Offline


Registered: 09/03/09
Loc: 10.6.8 (build 10K549)
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),


Edited by Hal Itosis (02/02/10 09:46 AM)

Top
#8126 - 02/02/10 04:03 PM Re: undo poof out of dock? [Re: Hal Itosis]
Virtual1 Offline


Registered: 08/04/09
Loc: Iowa
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

Top
#8128 - 02/02/10 04:16 PM Re: undo poof out of dock? [Re: Virtual1]
roger Offline


Registered: 08/04/09
Loc: Vermont
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

Top
#8158 - 02/03/10 03:57 PM Re: undo poof out of dock? [Re: roger]
joemikeb Offline

Moderator

Registered: 08/04/09
Loc: Fort Worth, Texas
There is. It is called Time Machine.
_________________________
joemikeb • moderator

Top
#8166 - 02/03/10 07:50 PM Re: undo poof out of dock? [Re: joemikeb]
Virtual1 Offline


Registered: 08/04/09
Loc: Iowa
I didn't know time machine could restore missing dock items. How do you do that?
_________________________
I work for the Department of Redundancy Department

Top
#8167 - 02/03/10 08:29 PM Re: undo poof out of dock? [Re: Virtual1]
MicroMatTech3 Offline


Registered: 08/04/09
You could restore the plist file at ~/Library/Preferences/com.apple.dock.plist .
_________________________
MicroMat Inc
Makers of TechTool

Top
#8168 - 02/03/10 08:38 PM Re: undo poof out of dock? [Re: MicroMatTech3]
Hal Itosis Offline


Registered: 09/03/09
Loc: 10.6.8 (build 10K549)
Third Base!

Top
#8171 - 02/04/10 05:16 AM Re: undo poof out of dock? [Re: joemikeb]
dkmarsh Offline

Moderator

Registered: 08/04/09

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

Top
#8172 - 02/04/10 05:49 AM Re: undo poof out of dock? [Re: dkmarsh]
alternaut Offline

Moderator

Registered: 08/04/09
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

Top
#8177 - 02/04/10 09:58 AM Re: undo poof out of dock? [Re: dkmarsh]
Hal Itosis Offline


Registered: 09/03/09
Loc: 10.6.8 (build 10K549)
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. . .

Top
#8180 - 02/04/10 03:08 PM Re: undo poof out of dock? [Re: Hal Itosis]
MicroMatTech3 Offline


Registered: 08/04/09
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

Top
#8183 - 02/04/10 04:42 PM Re: undo poof out of dock? [Re: MicroMatTech3]
dkmarsh Offline

Moderator

Registered: 08/04/09

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

Top
#8185 - 02/04/10 05:07 PM Re: undo poof out of dock? [Re: dkmarsh]
MicroMatTech3 Offline


Registered: 08/04/09
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

Top
#8196 - 02/05/10 11:48 AM Re: undo poof out of dock? [Re: MicroMatTech3]
roger Offline


Registered: 08/04/09
Loc: Vermont
"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

Top
#8198 - 02/05/10 01:53 PM Re: undo poof out of dock? [Re: roger]
Hal Itosis Offline


Registered: 09/03/09
Loc: 10.6.8 (build 10K549)
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.*


Edited by Hal Itosis (02/05/10 02:14 PM)

Top
#8203 - 02/05/10 09:02 PM Re: undo poof out of dock? [Re: Hal Itosis]
dkmarsh Offline

Moderator

Registered: 08/04/09

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

Top
#8204 - 02/05/10 09:42 PM Re: undo poof out of dock? [Re: dkmarsh]
Hal Itosis Offline


Registered: 09/03/09
Loc: 10.6.8 (build 10K549)
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?"


Edited by Hal Itosis (02/05/10 09:51 PM)

Top
#8210 - 02/06/10 06:41 AM Re: undo poof out of dock? [Re: Hal Itosis]
roger Offline


Registered: 08/04/09
Loc: Vermont
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

Top
#8213 - 02/06/10 07:20 AM Re: undo poof out of dock? [Re: roger]
alternaut Offline

Moderator

Registered: 08/04/09
Originally Posted By: roger
Finder - Edit - Undo Delete from Dock

Oops: Can't Undo shocked
_________________________
alternaut moderator

Top
#8214 - 02/06/10 07:23 AM Re: undo poof out of dock? [Re: roger]
Gregg Offline


Registered: 08/04/09
Loc: Milwaukee, WI (USA)
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.

Top
#8217 - 02/06/10 07:48 AM Re: undo poof out of dock? [Re: alternaut]
roger Offline


Registered: 08/04/09
Loc: Vermont
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

Top
#8220 - 02/06/10 09:03 AM Re: undo poof out of dock? [Re: roger]
Hal Itosis Offline


Registered: 09/03/09
Loc: 10.6.8 (build 10K549)
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'.


Edited by Hal Itosis (02/06/10 09:09 AM)

Top
Page 1 of 2 1 2 >

Moderator:  alternaut, dkmarsh, joemikeb