Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"BrowserWindow.webPreferences.icon" On ubuntu 24 doesn't show the app icon. #938

Open
EdgarRSSA opened this issue Sep 25, 2024 · 0 comments

Comments

@EdgarRSSA
Copy link

This doesn't show any icon*.png 😒 , some workaround? Greetings.

Pasted image

Pasted image (2)

node version : v22.7.0

Distributor ID:	Ubuntu
Description:	Ubuntu 24.04.1 LTS
Release:	24.04
Codename:	noble

Files:

.
β”œβ”€β”€ img
β”‚Β Β  β”œβ”€β”€ icon-128.png
β”‚Β Β  β”œβ”€β”€ icon-16.png
β”‚Β Β  β”œβ”€β”€ icon-256.png
β”‚Β Β  β”œβ”€β”€ icon-32.png
β”‚Β Β  β”œβ”€β”€ icon-64.png
β”‚Β Β  └── icon.png
β”œβ”€β”€ index.html
β”œβ”€β”€ LICENSE.md
β”œβ”€β”€ main.js
β”œβ”€β”€ package.json
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ preload.js
β”œβ”€β”€ README.md
β”œβ”€β”€ renderer.js
└── styles.css
![Pasted image](https://github.com/user-attachments/assets/0d240c40-6d31-42bd-8058-a0cb5242070d)

Package.json

{
  "name": "electron-quick-start",
  "version": "1.0.0",
  "description": "A minimal Electron application",
  "main": "main.js",
  "scripts": {
    "start": "electron ."
  },
  "repository": "https://github.com/electron/electron-quick-start",
  "keywords": [
    "Electron",
    "quick",
    "start",
    "tutorial",
    "demo"
  ],
  "author": "GitHub",
  "license": "CC0-1.0",
  "devDependencies": {
    "electron": "^32.1.2"
  },
  "icon": "./img/icon-32.png"
}

Main.js

const fs = require('fs');

const ICON_PATH = path.join(__dirname, "img", "icon-32.png")

function checkIconPath(iconPath) {

  if (fs.existsSync(iconPath)) {
    return;
  } else {
    console.error(`Not exists ${iconPath}`);
    process.exit(1);
  }

}
checkIconPath(ICON_PATH);



function createWindow() {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      icon: nativeImage.createFromPath(ICON_PATH),
    },
    icon: nativeImage.createFromPath(ICON_PATH),
  })

  // and load the index.html of the app.
  mainWindow.loadFile('index.html')

  // Open the DevTools.
  // mainWindow.webContents.openDevTools()
}

//                                                  ...
//                                                  ...
//                                                  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant