bayleeadamoss / zazu-file-finder

A file finder for Zazu.
18 stars 11 forks source link

[WIP] Add macOS app icons support #24

Closed twang2218 closed 7 years ago

twang2218 commented 7 years ago

Implement loading macOS app icons by reading Info.plist to get icon file, and convert to PNG by iconutil tool.

Replacing the dependency plist with simple-plist to support both text plist files and binary plist files.

After the Info.plist loaded, it uses CFBundleIconFile to locate the icon.

PNG files are converted from .icns by iconutil, which use external iconutil executable on macOS to do the conversion. To avoid EMFILE: too many open files problem, async.queue is used to limit the concurrent iconutil process.

The .icns usually contains multiple icons in various sizes, this implementation will choose the icon based on the priorities: 128 > 256 > the largest icon.

It will also handle the .tiff file if no .icns exists, the .tiff file will be converted to PNG file and stored to the cache by sip command line tool.

For those apps without icons, the system default app icon /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericApplicationIcon.icns will be used if it exists.

The PNG files of app icons are generated and stored in ${PLUGIN_DIR}/data/icons/ directory, with the file name ${APP_NAME}-${sha1(APP_PATH)}. Hashing the path to avoid the duplication, and with app name in it to make it easier to identify which app it's belong to.

Still working in progress.

2017-02-01 01 00 46

Signed-off-by: Tao Wang twang2218@gmail.com

bayleedev commented 7 years ago

This is a duplicate of #21

I'll take a look at both tonight to see if one works better than the other, but I'd advise checking open pr's so effort isn't duplicated in the future.

twang2218 commented 7 years ago

@blainesch I didn't realize there is a PR(and a branch) for this issue before I created the PR. I came from https://github.com/tinytacoteam/zazu/issues/138, and nothing mentioned/referenced on the issue for PR or branch, so I just blinded thought there wasn't one without checking. And I just realized it's duplicated after I created the PR, sorry for that. 😂

twang2218 commented 7 years ago

With today's update: