2
    "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

Rajesh Kumar J
  • 219
  • 1
  • 5
  • 8

1 Answers1

3

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

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
Seblor
  • 6,947
  • 1
  • 25
  • 46
  • 2
    yeah..that part is working fine But, when i build that as an application, the icon becomes empty I need to Know that, when i give the icon in BrowserWindow...i Dont need to give in the script part..Am I RIGHT?? – Rajesh Kumar J May 16 '18 at 12:34
  • I had to use `BrowserWindow({ icon: path.join(__dirname, 'path/to/image.png') })`. Specifying a relative path without __dirname specifically did not work on built linux applications. – No stupid questions Jan 24 '22 at 00:42