Danilo Ribeiro
Danilo Ribeiro

Reputation: 96

Electron Tray Icon not working on Ubuntu 20.04

Electron Tray icon is not showing correctly on Ubuntu 20.04 using Electron 13.1.2.

The icon should be the image set bellow:

function createTray() {
    const icon = path.join(process.resourcesPath, 'assets/favicon.png');
    tray = new Tray(nativeImage.createFromPath(icon));
    const contextMenu = Menu.buildFromTemplate([
        {
            label: 'Show',
            click: () => {
                createWindow();
            },
        },
        {
            label: 'Quit',
            click: () => {
                app.quit();
            },
        },
    ]);

    tray.setContextMenu(contextMenu);
    tray.setToolTip('Desktop Client');
    tray.setTitle('Desktop Client');

    showNotification();
}

But it shows a purple icon instead: screenshot

I used the same path to the app icon and notification icon and it worked (the blue atom icon): app icon notification icon

It also works well on Windows tray, and I don't know why it doesn't work on Ubuntu.

Here's the image in the project folder image in folder

I've tried to change the image resolution (16x16, 32x32, 64x64, 256x256) but nothing happened.

Upvotes: 2

Views: 1211

Answers (1)

wowestudy
wowestudy

Reputation: 38

If you give image path of dist folder, it will work perfect,

var tray = new Tray(path.join(__dirname, 'dist/assets/logo.png'))

Upvotes: 0

Related Questions