Warm tip: This article is reproduced from serverfault.com, please click

Electron macOS: Change icon of files

发布于 2020-11-28 16:34:25

we're trying to find and use an electron API that let us change the icon of a file (macOS only).

Our app accept a folder from the macOS finder and we want a way/api to get the current folder icon and change it by passing a new icns or png file. Is it possible?

Questioner
Mattia Astorino
Viewed
0
lifeisfoo 2020-11-29 01:18:16

You should use the NSWorkspace.setIcon function but there is no way to use this API from electron.

Looks like electron doesn't support the direct access to this API and some related issues exists.

As a workaround you can create (compile) a macos binary that only do this and then exec it from electron code using child_process.execFile.