Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron — Can't get custom icon to appear

I'm having an issue setting the icon for my Electron app in two different ways:

Non-Packaged (Running the app via terminal)

My main.js does specify an 'icon' value, pointing to the icon file, but it does not apply.

Packaged (with electron-packager)

My package.json file specifies the 'icon' key, pointing to the icon file, and I have the .icns (Mac) file in the build directory. I used electron-packager to build the app, but the icon is not applied, the default electron icon is used instead.

Not sure what I'm doing wrong here, everything appears correct.

like image 938
Karric Avatar asked Mar 20 '17 00:03

Karric


2 Answers

If you mean the icon on the dock, on MAC can should use:

const app = electron.app;
const image = electron.nativeImage.createFromPath(
  app.getAppPath() + "/public/YOUR_APP_IMAGE_NAME"
);
app.dock.setIcon(image);
like image 127
iharel Avatar answered Sep 28 '22 17:09

iharel


There is a good tutorial here:

  • https://www.christianengvall.se/electron-app-icons/

Follow the steps but make sure you don't skip anything.

This is also a relevant issue on GitHub:

  • https://github.com/electron-userland/electron-builder/issues/289

More links here:

  • https://discuss.atom.io/t/changing-electron-app-icon-and-information/18631
like image 44
rsp Avatar answered Sep 28 '22 17:09

rsp