onmyway133 / blog

🍁 What you don't know is what you haven't learned
https://onmyway133.com/
MIT License
675 stars 33 forks source link

How to change app icon in electron #66

Open onmyway133 opened 7 years ago

onmyway133 commented 7 years ago

Generate icns

icns

Use icns

win = new BrowserWindow({
  width: 800, 
  height: 600,
  icon: __dirname +  '/Icon/Icon.icns'
})

You can also use helper url methods

const path = require('path')
const url = require('url')

const iconUrl = url.format({
  pathname: path.join(__dirname, 'Icon/Icon.icns'),
  protocol: 'file:',
  slashes: true
})

If app icon is not updated

info

Release with electron-packager

aguynamedben commented 5 years ago

Did you end up finding a better way to do this? It seems the icon argument to BrowserWindow is ignored on macOS. The workaround (drag/drop) works for me, but I wish I could automate this so all developer on my team see a dev icon!

drewjosh commented 4 years ago

Is there any update on this issue? I am breaking my head because when I build and run the app (on Windows) with cli I see my icon in the taskbar. But when I install the app over an installer (icon of installer is also mine) and run it, it shows the default icon. The weird thing is, even in the OS settings where I can remove programs, my icon is shown...

I set the icon like this: mainWindow = new BrowserWindow({ width: 1280, height: 720, autoHideMenuBar: true, useContentSize: true, icon: 'src/client/assets/icons/logo.png'. });

Redsky48 commented 4 years ago

@drewjosh You should use it like this icon:__dirname +'/src/client/assets/icons/logo.png',