Adding buttons to Finder toolbar?

13,265

Solution 1

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.)

Solution 2

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.

Solution 3

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.

Solution 4

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.

Share:
13,265

Related videos on Youtube

cannyboy
Author by

cannyboy

Updated on June 24, 2022

Comments

  • cannyboy
    cannyboy about 2 years

    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!

  • Nico
    Nico over 12 years
    And the closest you can get to being a Finder toolbar item is to be an application that can open files and/or folders. Any such application can be added to a toolbar manually by the user (though it won't show up in Customize Toolbar). Time Machine is a good application to demonstrate this with.
  • cannyboy
    cannyboy over 12 years
    Looking at the Dropbox files in Library, I think it might be some sort of mach_inject thing, which is beyond my understanding. But google points me to github.com/rentzsch/mach_star
  • fny
    fny over 12 years
    @PeterHosey While drag and drop is possible, you can't achieve an pure styling that matches the native buttons without some sort of reverse engineering. The icons are generated from a series of transparent pngs, so even with well photoshopped icons, something will always feel amis.