Is there a unix tool to which I can pass a file and have it tell me where the icon for the file is coming from?
What I am looking for is something like this:
$WhoProvidedIcon /Path/To/file.myex
UTI: com.myapplication.document
PLIST: /path/to/myapplication.app/Contents/Info.plist
ICON: /path/to/myapplication.app/Contents/Resources/BaseDoc.icns
There are at least three different place from which the OS will provide the icon.
In one situation, NSWorkspace can be used to help identify the location:
This won’t quite get the path to the icon, but it will get one the application from which the declaration came for the UTI.
An icon might also be supplied from a Quick Look plugin and output from qlmanage can be used to determine if this is the case.
A user can, in Finder’s Get Info window, set the application they prefer for all files of a given “type”. One can set text file types to always open in TextMate, for example. TextMate the app provides custom file icons for all the file types it can save in. After making this change in Finder’s get info windows, all files of that type will have an icon that has been provided by TextMate and registered with a UTI. To determine whether this is the case, one would need to look at the launch services database – lsregister -dump