Question

Dropbox has the option of adding a button to the Finder toolbar. It even appears in the 'Customize Toolbar...' window.   I can't find any documentation on how this sort of thing is done.... Does anyone know how to do this, or can anyone point me towards some documentation or sample code?

EDIT ONE:

I guess a start would be finding the location of the existing icons, and any related code.

I noticed that Dropbox has files in Library/DropboxHelperTools/Dropbox_u501 called mach_inject_bundle_stub.bundle and FinderLoadBundle which might be doing the magic. Dropbox is also putting the 'tick' badge on Finder icons. This code might be involved: github.com/rentzsch/mach_star

EDIT TWO: A Dropbox talk by Rian Hunter about the process is here, at around 15:30 http://blip.tv/pycon-us-videos-2009-2010-2011/pycon-2011-how-dropbox-did-it-and-how-python-helped-4896698

Looking in the DropboxBundle file in the Dropbox_u501 shows the icons and some compiled code. The code suggests that Rian Hunter is the author: http://twitter.com/timeserena

Rian has his own version of the Mach Star code on his github - https://github.com/rianhunter/mach_star - tho it seems much older

EDIT THREE

There was a 'Code Injection Workshop' at Stanford a few weeks ago - http://stanfordacm.com/past/ - hosted by Rian. If anyone has notes from this please let me know!

Was it helpful?

Solution

Dropbox was using undocumented magic. There's no officially supported way to do this; the closest you can get without reverse engineering is Services.

(Update: As of macOS 10.11, what Dropbox was doing is no longer possible at all. System Integrity Protection now prevents code from being injected into system processes, such as the Finder.)

OTHER TIPS

You can use Finder Sync app extension(Starting in OS X v10.10).

A Finder Sync extension can:

  • Add, remove, and update badges and labels on items in a monitored folder.
  • Display a contextual menu when the user Control-clicks an item inside a monitored folder.
  • Add a custom button to the Finder’s toolbar.

Rian's talk at PyCon 2011 (on blip.tv) does not explain anything more than "We reverse-engineered Finder." Although the mach_star stuff is valuable, it still doesn't explain how to get a sidebar icon working. And the Stanford 'Code Injection Workshop' has not posted any content about this method.

I've nm'd and class-dump'd both bundles that Dropbox installs for each user under /Library/DropboxHelperTools, and the output provides good insight. If I get back to it, I'll finish my research and post it. Odds are, it won't be for some time, so here's hoping this nudge helps someone else.

An easy intermediate answer that may be adequate for some people is to simply create icons that look like buttons.

e.g. I created 'new text file here' and 'new terminal here icons' for my Finder:

enter image description here

The method can be found here.

The disadvantage is that they must be square and do not have animations/menus or show up in 'customize toolbar' etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top