MacOS – Change Mac OS X Finder sidebar icons

findermacossidebar

I have seen a lot of related questions/answers but it seems that there still isn't a working solution for it. So I have sum up all related info that I found and maybe we can find a solution to it.

So one of the way to do it is like in SIMBL's plugin for colored icons (google it) and like its done in Dropbox – inject code at mach_kernel. But I don't like this idea with code injection and it seems that there can be a simpler way with modification of system resources.

So all data for sidebar entries is stored in ~/Library/Preferences/com.apple.sidebarlists.plist
(It's binary plist, open it with Xcode/PlistEditPro/etc)
favorites -> VolumesList

icon for entry is defined with a pair of data: Icon and CustomItemProperties -> com.apple.LSSharedFileList.TemplateSystemSelector

that mean that it is possible to change Alias to custom for default entries, or adding Icon and CustomItemProperties -> com.apple.LSSharedFileList.TemplateSystemSelector to custom entry with data copied from default entries and it will work.

You need to log off -> log in to see changes.

But with that you only can change entry image that already is in system. So I looked more detailed to fields Icon and CustomItemProperties -> com.apple.LSSharedFileList.TemplateSystemSelector

Field Icon is hex encoded and decoded it looks like that:

ImgR��4����FBIL��(����������������ћЊщ��H+�����ю≤�€\��ћCW����     €ю��������€€€€���ю≤�юD�юC�з�^~�^{��@��T�o�o�l�b�a�r�D�o�c�u�m�e�n�t�s�F�o�l�d�e�r�I�c�o�n�.�i�c�n�s����M�a�c�H�D��_System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDocumentsFolderIcon.icns���/�€€

(default Documents field)

So it's pointing to normal, colored documents icons file. Changing data for another .icns file (even valid or from another default icon) make entry show default stock folder icon.
But if change it to another default icon and then change com.apple.LSSharedFileList.TemplateSystemSelector like in that icon then it will show that another default icon.

com.apple.LSSharedFileList.TemplateSystemSelector looks like this:

1935819875

(default Documents field)

This means that Icon data and com.apple.LSSharedFileList.TemplateSystemSelector number are related and pair of them determines entry icon. I'm not figured yet what is this number and what it means, but for default entries it always begins with 19358**. I think it's related to CoreServices.framework header LSSharedFileList.h and it's number of entry in some kind of system resources list.

Is there someone know what to do next? I would be grateful if you could help me with it.

Here is list of default entries data http://www.mediafire.com/view/?l5sqalslbcxj2dl
It will help you if you want to change your stock folder icons in sidebar to icons from default entries.

Best Answer

This isn't an answer but it does add some information. The value associated with the com.apple.LSSharedFileList.TemplateSystemSelector key, 1935819875, is a decimal representation of the file type. In hex, it is 0x73624463, which are the ascii letters 'sbDc'. This file type is described in /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist. This is a binary plist that you can convert to xml using plutil -convert xml1 -o Info.plist.xml Info.plist. Looking in the Info.plist.xml file, you can see a dictionary at the top level. Inside this there is a key "CFBundleDocumentTypes" and an array of dictionaries as its value. In this array is a dictionary that contains the following:

<dict>
    <key>CFBundleTypeIconFile</key>
    <string>SidebarDocumentsFolder.icns</string>
    <key>CFBundleTypeName</key>
    <string>Sidebar Documents Folder Icon</string>
    <key>CFBundleTypeOSTypes</key>
    <array>
        <string>sbDc</string>
    </array>
    <key>CFBundleTypeRole</key>
    <string>None</string>
    <key>LSTypeIsPackage</key>
    <false/>
    <key>NSPersistentStoreTypeKey</key>
    <string>Binary</string>
</dict>

An interesting key/value pair in this dictionary is CFBundleTypeIconFile: SidebarDocumentsFolder.icns. This file can be found at /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SidebarDocumentsFolder.icns and it contains the icons used for document folders.

I would think that changing the com.apple.LSSharedFileList.TemplateSystemSelector value to a different value, or updating the dictionary for 'sbDc' to refer to a different icns file would get you on your way to having custom icons.