Ji4n1ng / OpenInTerminal

✨ Finder Toolbar app for macOS to open the current directory in Terminal, iTerm, Hyper or Alacritty.
MIT License
5.85k stars 234 forks source link

Adaptive light and dark mode icons? #211

Open AlexanderOMara opened 7 months ago

AlexanderOMara commented 7 months ago

Summarize this feature

According to Wikipedia it's possible to create an icns file with a dark mode embedded inside of a light mode icns file.

Why should this feature be included?

Convenience and presumably auto-adaptive?

Additional information

Assuming this works how I think it would, this would be especially good for the Lite versions of this app.

If anyone knows of any samples of such an icon, that might be helpful to play around with. I'm not sure what the official procedure to make one is and the iconutil man pages don't cover it.

AlexanderOMara commented 7 months ago

Found some samples:

/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/TrashIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FullTrashIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/EjectMediaIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/UsersFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/DocumentsFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ApplicationsFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/PicturesFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/PublicFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SystemFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Everyone.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ServerApplicationsFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/LibraryFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SmartFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BurnableFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GuestUserIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/UtilitiesFolder.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericSharepoint.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/MovieFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/DownloadsFolder.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/UserUnknownIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GroupFolder.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GroupIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/DeveloperFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/MusicFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/DesktopFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SitesFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/UserIcon.icns

Unfortunately iconutil does not appear to support unpacking (or packing?) the dark icons. It is technically possible to create them though, and the file format is fairly simple.

I played around with TrashIcon.icns and it does automatically adapt to the Light/Dark mode setting. The only deficiency I found was app icons in the Finder toolbar do not automatically switch like they do elsewhere in Finder, it does not change until a relaunch of Finder. Could be better, maybe a bug on Apple's part, but only an issue if you actually change your theme or set it to change automatically.

jsx97 commented 4 months ago

I played around with TrashIcon.icns and it does automatically adapt to the Light/Dark mode setting.

Hi, Alexander. Could you explain how exactly I can get access or extract dark icons from TrashIcon.icns?

AlexanderOMara commented 4 months ago

@jsx97 I don't know of any existing tools, but it's pretty simple. Find the chunk inside TrashIcon.icns named FD D9 2F A8, copy it, and overwrite FD D9 2F A8 with icns. That will make it a valid icns file. From there you can extract the individual icons from the dark icns file using a tool like iconutil.

jsx97 commented 4 months ago

Many thanks. But I'm not sure I understand the first part. I have opened the file using the Hex Fiend editor and I was able to find the FD D9 2F A8 chunk. But how to overwrite it? When I type ic in the "Replace" field, it results in 0C, but then nothing happens. Typing ns after ic doesn't make any effect.

image
AlexanderOMara commented 4 months ago

I'd recommend making a copy of the icns file, finding FD D9 2F A8, selecting all the hex on the left that comes before it, deleting it, then on the right side overwrite the first 4 bytes with icns, and save.

mjsarfatti commented 5 days ago

Chiming in to say that this is how the icons appear in dark mode on macOS Sonoma. They look disabled, even though the app works as expected if I click on them.

Screenshot 2024-08-13 at 01 50 34