Closed twang2218 closed 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.
@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. 😂
With today's update:
Implement loading macOS app icons by reading
Info.plist
to get icon file, and convert to PNG byiconutil
tool.Replacing the dependency
plist
withsimple-plist
to support bothtext plist
files andbinary plist
files.After the
Info.plist
loaded, it usesCFBundleIconFile
to locate the icon.PNG files are converted from
.icns
byiconutil
, which use externaliconutil
executable on macOS to do the conversion. To avoidEMFILE: too many open files
problem,async.queue
is used to limit the concurrenticonutil
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 bysip
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.
Signed-off-by: Tao Wang twang2218@gmail.com