The other day I saw this tweet:
I use a PARA method-derived folder scheme, so I thought colour-coding the folders would be neat. But I was disappointed to find this isn’t a native macOS feature. The OP made the icons with Figma which seems very labour-intensive. Can we do better?
The default macOS folder icon is here:
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericFolderIcon.icns
This is an ICNS file, an archive of PNG images. Using iconutil
you can explode t:
$ iconutil -c iconset GenericFolderIcon.icns
This creates a GenericFolderIcon.iconset
directory with these contents:
icon_128x128.png
icon_128x128@2x.png
icon_16x16.png
icon_16x16@2x.png
icon_256x256.png
icon_256x256@2x.png
icon_32x32.png
icon_32x32@2x.png
icon_512x512.png
icon_512x512@2x.png
And with ImageMagick you can apply colour changes. I experimented with a few options, the hardest parts are getting away from the initial blue bias, and preserving the drop shadow. This works somewhat:
$ magick default.png -modulate 100,0,100 -fill '#ef4444' -colorize 70 red.png
Turning this:
Into this:
If you this for each PNG in the iconset, the dual command:
$ iconutil -c icns Icon.iconset
Will turn the Icon.iconset
folder into an ICNS folder Icon.icns
.
Okay, so we have the existence proof that we can make a tolerable icon, and we know the mechanics of ICNS -> List[PNG] -> ICNS
. Now we have to scale this up.
I started out with a Makefile, but make is really only tractable if you hardcode the dependency DAG. If you want to derive the DAG from a data structure (e.g., the colour palette) the code quickly becomes write-only.
Fortunately I have a Python interpreter, and an infinitely-industrious alien buddy who turns natural language into code. So I had Claude write a Python script that generates a tinted ICNS file for each colour in the Tailwind colour palette. And this is the result:
Which I think is pretty good for a half hour project. The code is here.
This is great example of how LLMs reduce the activation energy for tiny projects like this. Without Claude, I probably would not have bothered writing the entire Python script from scratch.