I posted this the other day in the general Lion discussion thread, but I kind of think it would be better to have its own thread. Hopefully the moderators will agree, but if not, feel free to move or delete this thread.

So I'm among the users going crazy thanks to apple's new "no custom sidebar icons in finder" decision. I can live without color icons, so long as I can at least assign custom icons again to differentiate between all the folders I add to my sidebar. So I've been digging through OSX trying to find a way to at least hack in support for custom icons again, but I've hit a wall, and would love some help and feedback from anyone else working on custom icons too.

Anyway, onwards!

So its easy enough to find the current icons in /system/library/coreservices/coretypes.bundle/contents/resources since they're all prefaced with Sidebar, and each has 32px and 16px monochrome resources for the new cocoa sidebar processing.

Now, go up a level and look in info.plist, and you can see that every default sidebar icon has a registered Document Type.

For example, "Sidebar All My Files Icon" has the Document OS Types set to: "sbAF"

So, next step, I made a blank text document, and using setFile from the command line, ran:

setFile -type 'sbAF' somefile.rtf

Now, after this, dragging somefile.rtf into the sidebar gave it the "All My Files" icon instead of the generic document icon. Since apple stopped using creator/type codes in snow leopard, this is an easy enough solution if you add specific documents to your sidebar.

However, I can't find a way to set a type for folders, well, because they're folders after all and don't have a type. So then I tried using an alias to a folder, and while you can set the 'type' for an alias, when you try to drag it into the sidebar, it drags the original location, and not the alias, and thus no custom icon :(

Any thoughts?

My best guess is that there's a hard coded list somewhere of what directories get custom icons, and if so, then its just a matter of time of finding it before we can add/delete/modify custom icons. And then it should be easy enough to add new icons to coretypes.bundle, I know that's a scary thought, but there's not much else I can think of unless apple decides to build custom icon support into a future update.

Cheers everyone, :)
Sidebar icons in Lion are taken from icons masks. Unless someone (who?) finds a way to colorize masks (I think it's just impossible), there will be no chance to get a bit of color in sidebars.

Sorry. :(
That's a great find mjmallon. But I think an anti-mod is hardcoded in Finder.

I tried setFile -type 'sbAF' somefolder and it did change the folder type. You can check using the mdls command.

But somehow it shows up as having the type 'AFsb' (which is actually sbAF reversed). Somewhat weird but easily fix-able by using setFile -type 'AFsb' somefolder instead.

But still, after getting the correct type, when dragging the folder to the sidebar it still showed up as a generic folder.
Ok, mdls is just a Spotlight-related command. Looking at setfile's developer documentation the correct command to check the type is getfileinfo -t <path> and it refuses directories.

Looks like a filesystem limitation - So you're right, there's no way of having a folder with an OSType. (Apple must have used some black sorcery or something :-!)

Also, even though there are 4 methods of type declaration (OSType, MIME, UTI and Extension), putting anything in that Info.plist that's not OSType is ignored. <_<
inket wrote:Ok, mdls is just a Spotlight-related command. Looking at setfile's developer documentation the correct command to check the type is getfileinfo -t <path> and it refuses directories.

Looks like a filesystem limitation - So you're right, there's no way of having a folder with an OSType. (Apple must have used some black sorcery or something :-!)

Also, even though there are 4 methods of type declaration (OSType, MIME, UTI and Extension), putting anything in that Info.plist that's not OSType is ignored. <_<

Hi,

I was just getting ready to type up a response about mdls, but you beat me to it, lol.

I'm still searching for some kind of solution, the last thing I tried was looking in the com.apple.sidebarlists.plist file in ~/library/preferences.

It seems that items with apple-defined custom icons get a select handful of unique keys:

1) and actual icon data key, but I've looked at the plist in binary1 and xml1 and can't figure out what the data means

2) an "EntryType" key, and this seems to have specific settings (though I'm not sure I fully understand their meanings) like 513 = usb disk, 515 = disk image. 261 = internal hard disk

3) a key under "customitemproperties" called: com.apple.LSSharedFileList.TemplateSystemSelector with various numeric values, like entry type, these also seem specific, but again, I might just be completely wrong:

Applications: 1935819120
Desktop: 1935819892
Downloads: 1935819884
named used home dir: 1935820909
documents: 1935819875
movies: 1935822198
music: 1935822195
pictures: 1935822947
dropbox/user public folder: 1935819842
generic folder icon: 1935820388

And of course, the bad news, changing anything in this plist, to use a custom icon (I tried copying the icon key and numeric value for "Drop Box" to another folder in my sidebar, doesn't work, finder just rejects it, and rewrites the original data.

So, back to thinking there's a hard coded list somewhere, that finder parses for determining sidebar icons, and it has to rely on some kind of external source. I have an SSD and an HDD in my laptop, so when I moved my user directory to the HDD, if I dragged that folder into the sidebar, it was just a folder. But after setting the home directory location via system preferences, now it has the custom icon (rightly so.)

So finder is getting some locations via the directory or some other external config somewhere.

Ugh, I still can't believe someone at apple decided having no custom icon support was the right decision.

:(
Excuse me, I don't understand what exactly you're trying to do... If I'm not wrong, you want to customize the sidebar icons, right? Well... why do you think there's something hard-coded somewhere? :/

As I said before,

egon1984 wrote:Sidebar icons in Lion are taken from icons masks. Unless someone (who?) finds a way to colorize masks (I think it's just impossible), there will be no chance to get a bit of color in sidebars.

Sorry. :(
egon1984 wrote:Excuse me, I don't understand what exactly you're trying to do... If I'm not wrong, you want to customize the sidebar icons, right? Well... why do you think there's something hard-coded somewhere? :/

As I said before,

egon1984 wrote:Sidebar icons in Lion are taken from icons masks. Unless someone (who?) finds a way to colorize masks (I think it's just impossible), there will be no chance to get a bit of color in sidebars.

Sorry. :(


Hi,

Yes, I'm trying to enable custom sidebar icons again the finder. But If you read my posts, you see that I'm not trying to colorize the icons, I'm ok with the greyscale/monochrome type look, but I usually drag 8-10 folders into my sidebar, and would really like to have some kind of custom icons back, even just monochrome/greyscale.

And this thread is to try and understand how apple is calling specific icons for some folders (~/Desktop or /Applications/Utilities for example) but then only calling the same generic folder or document icon for anything else dragged into the sidebar.

For example, any folder that's not one of a few pre-defined folders by apple, when dragged into the sidebar, is given an icon (as you say, its generated from the mask, so ok) but regardless, that doesn't come from a custom icon attached to the folder, but from one specific icns file:

/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SidebarGenericFolder.icns

And any document will be given an icon from:

/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SidebarGenericFile.icns

In fact, every icon in the sidebar is drawn from one of these new SidebarXXXXXXX.icns files, and not the file attached to the app/folder/dolcument/etc., so finder somewhere is referencing a list to resolve/determine which SidebarXXXXXXXX.icns file to assign to specific sidebar items.

Also, if you'd read my post, you'd see that I already found one such list, using apple's now deprecated 'FSType' attribute in:

/System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist

And have already been able to spoof finder into assigning custom icons for documents dragged into the sidebar, using setfile -type.

Here's an example to help explain/illustrate.

Original: Image
setfile: Image
New icon: Image

So now I'm just trying to figure out how to do something similar with folders/directories, since they can't have an FSType attribute.

Hope that clears things up.

Cheers everyone, :)
Now I do understand. :)
My fault, I'm sorry. I got lost in the first long message.
I apologize.
Nice find, again.

I tried a few things and it turns out the Icon and Alias data keys are both aliases. (Icon is an alias to the icns and Alias is an alias to the actual folder)

A special kind of alias, though...

Image

Maybe if we can make aliases like this we can add them to the plist and it would work. I'm still trying a few things.
So I've been all over this for the past 2 days and couldn't find any way to put custom icons for folders using either the sidebarlists.plist or the Info.plist.


But instead I came up with a really dirty way which involves putting a file on the sidebar, setting its OSType (thus, changing the icon) and having that file open an app that redirects Finder to the correct location.

Basically, it acts as a file (animation, no selection, etc.) but it gets you were you want to go and has the icon you choose. Here's a video to show you how it works: http://cl.ly/9GHJ

Now, I don't know if anyone is interested in this half-assed solution, but it could be ready by tomorrow if someone wants it.

Until someone comes up with a real solution.
inket wrote:So I've been all over this for the past 2 days and couldn't find any way to put custom icons for folders using either the sidebarlists.plist or the Info.plist.


But instead I came up with a really dirty way which involves putting a file on the sidebar, setting its OSType (thus, changing the icon) and having that file open an app that redirects Finder to the correct location.

Basically, it acts as a file (animation, no selection, etc.) but it gets you were you want to go and has the icon you choose. Here's a video to show you how it works: http://cl.ly/9GHJ

Now, I don't know if anyone is interested in this half-assed solution, but it could be ready by tomorrow if someone wants it.

Until someone comes up with a real solution.

Hey again,

That's further than I've managed to get the past couple of days, I'd love to see how you've made a file re-direct the finder window, even though it is kind of (like you said) half-assed.

Cheers, :)
I imagine you could simply make an Applescript which does that, so you don't even need to know any objc to do it. In fact, I think you could even use an Automator workflow…?

I was going to suggest that you try making an app which opens the folder in the Finder, but after I'd typed my comment out I went to make sure that apps' appicon.icns was actually the image shown in the sidebar (i.e. that apps have their own icons in the sidebar) but it's just a generic app icon, so I deleted my comment and never thought any more of it.
mjmallon wrote:Hey again,

That's further than I've managed to get the past couple of days, I'd love to see how you've made a file re-direct the finder window, even though it is kind of (like you said) half-assed.

Cheers, :)

The redirect uses ScriptingBridge (AppleScript in Objective-C); Check these two lines.

dr.vox wrote:I imagine you could simply make an Applescript which does that, so you don't even need to know any objc to do it. In fact, I think you could even use an Automator workflow…?

It's more about speed and simplicity actually. I uploaded it to github if you want to take a look. Here. Still needs the companion app but you get the idea.

dr.vox wrote:I was going to suggest that you try making an app which opens the folder in the Finder, but after I'd typed my comment out I went to make sure that apps' appicon.icns was actually the image shown in the sidebar (i.e. that apps have their own icons in the sidebar) but it's just a generic app icon, so I deleted my comment and never thought any more of it.

Yeah, folders can't have custom icons in the sidebar (yet) and apps are folders. :/
inket wrote:
mjmallon wrote:Hey again,

That's further than I've managed to get the past couple of days, I'd love to see how you've made a file re-direct the finder window, even though it is kind of (like you said) half-assed.

Cheers, :)

The redirect uses ScriptingBridge (AppleScript in Objective-C); Check these two lines.

dr.vox wrote:I imagine you could simply make an Applescript which does that, so you don't even need to know any objc to do it. In fact, I think you could even use an Automator workflow…?

It's more about speed and simplicity actually. I uploaded it to github if you want to take a look. Here. Still needs the companion app but you get the idea.

dr.vox wrote:I was going to suggest that you try making an app which opens the folder in the Finder, but after I'd typed my comment out I went to make sure that apps' appicon.icns was actually the image shown in the sidebar (i.e. that apps have their own icons in the sidebar) but it's just a generic app icon, so I deleted my comment and never thought any more of it.

Yeah, folders can't have custom icons in the sidebar (yet) and apps are folders. :/

So after your post I went ahead and started playing with automator, and you can do almost the same thing with it just using a workflow file.

Hide extension, name it whatever you want, and do the setfile -type.

Its not really as clean as yours though, since it will open a new window instead of using the existing window (or in my case, it opens a new totalfinder tab) so yeah, definitely still half-assed.

Ugh, I still don't even remotely understand this decision by apple.

:(
mjmallon wrote:Its not really as clean as yours though, since it will open a new window instead of using the existing window (or in my case, it opens a new totalfinder tab) so yeah, definitely still half-assed.

I thought that would be the case, that's why I tacked it on the end there… With AppleScript you can definitely tell Finder to go to the directory in the current window. You probably can using Automator too, but I've never looked far into Automator (in fact I don't think I've launched it for about six months…).
Its not really as clean as yours though, since it will open a new window instead of using the existing window (or in my case, it opens a new totalfinder tab) so yeah, definitely still half-assed.

Couldn't you just run Applescript in the workflow, telling Finder to set the target of window 1 (the frontmost window) to the folder you want?
Code: Select all
property the_path : "/Users/Steven/Desktop/"

set the_folder to (POSIX file the_path) as alias
tell application "Finder"
   set target of window 1 to the_folder
end tell

This works but not well. Ok it works well but its ugly.
I saved it as an application and put it in the sidebar. It opens the correct folder, but since it first opens the application, Finder loses focus, an app icon appears in the dock for a second, then finder comes back into focus.

This is the shallow extent of my knowledge.
Guys, can anyone explain this behavior with the sidebar? Finder looks "normal" but if I open the file dialog from a VST synthesizer plugin everything is way darker, and it looks like this:

Image
Last edited by Fzang on August 14th, 2011, 9:36 pm, edited 1 time in total.
NoSmokingBandit wrote:
Code: Select all
property the_path : "/Users/Steven/Desktop/"

set the_folder to (POSIX file the_path) as alias
tell application "Finder"
   set target of window 1 to the_folder
end tell

This works but not well. Ok it works well but its ugly.
I saved it as an application and put it in the sidebar. It opens the correct folder, but since it first opens the application, Finder loses focus, an app icon appears in the dock for a second, then finder comes back into focus.

This is the shallow extent of my knowledge.

You can do pretty much the exact same thing with just using an automator workflow.

Add the "run applescript command" and paste the following, change folders/disk structure as necessary:

Code: Select all
tell application "Finder"
   activate
   set target of Finder window 1 to folder "Library" of folder "jocelyn" of disk "LappyHD"
end tell

Then show contents, browse to the actual document.wflow file, setfile -type on the document.wflow file, rename it if you want, and drag that to the sidebar.

Finder will lose focus for a second, it has to because it is launching a document, not actually switching folders properly, but at least it won't show an app icon in the dock.

Of course, this is still not without issue, since it seems to mis-align the window contents for me.

And of course if you want to hide them, just create a hidden folder somewhere like .workflows and move the .wflow files in there.

I'm using this for now, but personally I still don't like it, and want to find out exactly where/how finder is allowing specific folders to have custom icons. I'm convinced it has something to do with the OSType variable, even though supposedly folders can't have that property, I'm wondering if it has to do with badging the folders in code?

I.e., I'm thinking we may need to write a headless/background app to badge the folders with OSType variables, in order for finder to assign them icons. Of course, I can't program anything at all, so this is way beyond me now :(


Cheers, :)
Is this work? http://www.youtube.com/watch?v=ooD4QF68G8s
I haven't used SIMBL yet. Is this safe?
costee wrote:Is this work? http://www.youtube.com/watch?v=ooD4QF68G8s
I haven't used SIMBL yet. Is this safe?

Hi,

Thanks for pointing that out, I just set that up and its working quite well.

SIMBL used to have some issues on earlier OSX builds if you ran tons of mods, but I personally think that was usually the mod authors fault, and not SIMBL's.

A quick note, if you don't want to use applescript, you can setup the color sidebar on boot using a launchagent and shell script

the launchagent plist file I made:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>com.colorsidebar.root</string>
   <key>KeepAlive</key>
   <false/>
   <key>RunAtLoad</key>
   <true/>
   <key>ProgramArguments</key>
   <array>
      <string>/Volumes/LappyHD/jocelyn/bin/colorsidebar.sh</string>
   </array>
</dict>
</plist>

and the script (for totalfinder users) is the same as the videos:

Code: Select all
#!/bin/bash
#
#This file kills the finder on user session start
#and re-launches TotalFinder
#

killall Finder
Open /Applications/TotalFinder.app

Paste the plist into a text file and save it as com.colorsidebar.root.plist in the ~/Library/Launchagents folder, be sure to modify the past for wherever you decide to store your shell scripts. I keep mine in ~/bin personally.

Then make sure to set read and execute permissions on both the plist and the shell script.

And of course, you can modify the shell script if you don't use totalfinder, just add an # to the beginning of the 'open /Applications/TotalFinder.app' line

I'm also convinced that this can somehow be merged into just the plist, but setting the ProgramArguments to the following doesn't work for me:

Code: Select all
   <key>ProgramArguments</key>
   <array>
      <string>/bin/bash</string>
      <string>killall Finder</string>
      <string>open /Applications/TotalFinder.app</string>
   </array>

console shows the error is "8/21/11 5:16:16.957 PM com.colorsidebar.root: /bin/bash: killall Finder: No such file or directory
"

Cheers, :)
Looks good.
Well, thanks to a quick response from another forum, I've fixed the launchagent plist to not need the shell script.

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>com.colorsidebar.root</string>
   <key>KeepAlive</key>
   <false/>
   <key>RunAtLoad</key>
   <true/>
   <key>ProgramArguments</key>
   <array>
      <string>/bin/bash</string>
      <string>-c</string>
      <string>killall Finder; open /Applications/TotalFinder.app</string>
   </array>
</dict>
</plist>

Save as com.colorsidebar.root.plist in ~/Library/LaunchAgents and set read and execute permissions.

If you aren't using TotalFinder, you can replace

Code: Select all
/Applications/TotalFinder.app

with

Code: Select all
/System/Library/CoreServices/Finder.app

to automatically relaunch finder.

I'm so very happy to have color and custom icons back, though it doesn't propagate to file open/save dialogues for some reason :(

Image

Cheers everyone!

:)
Last edited by mjmallon on August 22nd, 2011, 7:02 am, edited 1 time in total.
Wahou, this it just awesome... :D
Thanks for the finding !
I must be doing something wrong or absolutely braindead and missing something - I pasted those plist contents into the proper directory and rebooted - no change.

Please, no laughing - but help? :lol: