How to set app icon for Electron / Atom Shell App

2019-01-16 05:05发布

问题:

How do you set the app icon for your Electron app?

I am trying BrowserWindow({icon:'path/to/image.png'}); but it does not work.

Do I need to pack the app to see the effect?

回答1:

Setting the icon property when creating the BrowserWindow only has an effect on Windows and Linux.

To set the icon on OS X, you can use electron-packager and set the icon using the --icon switch.

It will need to be in .icns format for OS X. There is an online icon converter which can create this file from your .png.



回答2:

Below is the solution that i have :

mainWindow = new BrowserWindow({width: 800, height: 600,icon: __dirname + '/Bluetooth.ico'});


回答3:

You can do it for macOS, too. Ok, not through code, but with some simple steps:

  1. Find the .icns file you want to use, open it and copy it via Edit menu
  2. Find the electron.app, usually in node_modules/electron/dist
  3. Open the information window
  4. Select the icon on the top left corner (gray border around it)
  5. Paste the icon via cmd+v
  6. Enjoy your icon during development :-)

Actually it is a general thing not specific to electron. You can change the icon of many macOS apps like this.