2

I'm trying to set an electron icon for my app. I try this:

mainWindow = new BrowserWindow({ width: 1280, height: 768, icon: __dirname + "/logo.ico" });

But it doesn't works for me. I read in others questions (like this) that setting the icon property when creating the BrowserWindow only has an effect on Windows and Linux. But I'm currently on Linux, not in Mac OS.

How can I deal with this? Must the icon have a fixed size or something?

Thanks in advance!

Community
  • 1
  • 1
Abel
  • 355
  • 9
  • 20
  • 1
    facing the same issue. have you find any answer to the question – shiv garg Jul 20 '16 at 20:34
  • Finally I got through Electron packager with --icon option. The icon can not have size 128x128px, and must have .ico format. So it worked for me. E.g: electron-packager . appName --platform=win32 --arch=all --icon='/path/logo.ico' --asar=true --prune --overwrite – Abel Jul 21 '16 at 07:29
  • 1
    size less than or greater than 128x128px supported? – shiv garg Jul 21 '16 at 07:50

1 Answers1

2

I just chased this question around for half an hour. What worked for me (running on windows), was I had to modify my path. Working in electron, I was too used to loading URLs, (win.loadURL(dirName/index.html)). So, when I went to put in my icon, I made the mistake of using file://dirName/index. It will NOT accept your image if you begin with file://. So, just write your path, e.g. C://Users/etc/icon.png. I don't know that this fixes all cases of this problem, but it was what was causing my image not to show.

sabbir
  • 2,020
  • 3
  • 26
  • 48
EvSunWoodard
  • 1,270
  • 1
  • 10
  • 28