Electron-builder: Change tray icon on runtime

Created on 26 Jun 2018  路  3Comments  路  Source: electron-userland/electron-builder

  • Version: 20.15.1
  • Target: Windows

Hello!

I have an application that is syncing a folder, and the tray icon should show what action the app is doing (upload, download, etc.). For that I need to change the icon on runtime. I did it using the tray.setImage() method, where tray is only one instance, created when the application starts. While doing so, I didn't have any issues in development, but after I build the application, the icon stopped changing.

Is this something that electron-build supports, or should this be handled somewhere else? Is this even the correct project to ask my question?

PS: Found the issue, the code wasn't being executed at all.

question

Most helpful comment

Hi @mattfwood!
Basically I keep 2 variables with the image directories - in development and in production and I use the electron-is-dev package to decide which directory should be used in run time. When I want to update the icon, I simply call tray.setImage() with the icon path.

Hope I was able to help! :)

All 3 comments

@vkolova Would you be able to share a snippet of the code you're using to set images? I'm trying to do something similar and I'm having a similar issue. Also, after packaging, my app won't start because it can't resolve the tray icon path.

Any help would be greatly appreciated. Thanks!

Hi @mattfwood!
Basically I keep 2 variables with the image directories - in development and in production and I use the electron-is-dev package to decide which directory should be used in run time. When I want to update the icon, I simply call tray.setImage() with the icon path.

Hope I was able to help! :)

@mattfwood Use extraResources to bundle images as part of your app.

Was this page helpful?
0 / 5 - 0 ratings