Reputation: 219
"package-linux": "electron-packager . Desktop-Wallet --overwrite --asar=true --platform=linux --arch=x64 --icon=./assets/icons/png/4.png --prune=true --out=release-builds"
this is the package.json script for developing linux app. while running the electron locally the icon is visible, but when I developed it as an application it is not showing the icon
Upvotes: 2
Views: 5184
Reputation: 51
There are many places to put your icon. But two main files.
In your main.js you should have it set for every window that you populate:
App.mainWindow = new BrowserWindow({ icon: "./assets/icon.ico"})
In your electron builder config. This may be either in your package.json or in a standalone file which you include through a script in your package.json
script --->("make-win": "electron-builder --config electron-builder-win.json --publish always ")
Windows desktop icon --> "win": { "icon": "assets/icon.ico"}
Windows Installer Icon --> nsis:{ "installerIcon": "assets/icon.ico", "uninstallerIcon": "assets/icon.ico",}
Please note, the above examples utilize webpack and move ./assets into assets upon creation of the executable. The rules are similar for mac and linux, pay close attention to the size of your icons and reference official documentation for specific builds (dmg, etc)
Upvotes: 0
Reputation: 7146
You need to set the icon in the BrowserWindow constructor:
BrowserWindow({ icon: 'path/to/image.png' })
Also, from the documentation:
Please note that you need to use a PNG, and not the macOS or Windows icon formats, for it to show up in the dock/window list. Setting the icon in the file manager is not currently supported.
Documentation:
https://www.electronjs.org/docs/latest/api/browser-window/#new-browserwindowoptions
https://electron.github.io/electron-packager/main/interfaces/electronpackager.options.html#icon
Sources:
How to set app icon for Electron / Atom Shell App
https://github.com/electron-userland/electron-builder/issues/2269#issuecomment-342168989
Upvotes: 3