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

Icon not working on linux #19

Open
tomasbulva opened this issue Sep 27, 2019 · 5 comments
Open

Icon not working on linux #19

tomasbulva opened this issue Sep 27, 2019 · 5 comments

Comments

@tomasbulva
Copy link

tomasbulva commented Sep 27, 2019

const aboutData = {
    icon: path.join(__dirname, 'build/icons/icon.png');,
    title: packageJson.productName,
    copyright: `Copyright ${year} ${packageJson.author.name}`,
    website: packageJson.author.url,
    text: packageJson.description,
}

click() {
    showAboutWindow(aboutData);
}

This exact code works on windows and mac but not on linux:

AppImage ( ubuntu / pop_os ) and dep package
electron 5.0.7
electron-builder 21.1.3

remmina-141057 722727
Screenshot from 2019-09-27 15-41-10
Screenshot from 2019-09-27 16-28-44

@sindresorhus
Copy link
Owner

Are you sure the path.join(__dirname, 'build/icons/icon.png') path is included in the built app? I'm asking as the build folder is usually used by electron-builder, but not included in the actual app.

@tomasbulva
Copy link
Author

Yes this path exists, and the same code works in windows build and mac build (I'm not sure if this your software is being used to generate mac about window).

Here is tree from unpacked app.asar:

app
├── build
│   ├── asset-manifest.json
│   ├── env
│   ├── favicon.ico
│   ├── icons
│   │   ├── icon.ico
│   │   └── icon.png
│   ├── images
│   │   ├── gradient-check.png
│   │   ├── manage-tokens.png
│   │   ├── menu-logo.svg
│   │   ├── monster.png
│   │   └── no-transactions-arrow.png
│   ├── index.html
│   ├── js
│   │   ├── browser-window-preload.js
│   │   ├── lynx-mobile-sdk.js
│   │   └── webview-functions.js
│   ├── manifest.json
│   ├── precache-manifest.4c014bfb3e996810132fa7b5a34136f3.js
│   ├── service-worker.js
│   └── static
│       ├── css
│       │   ├── main.30b8712a.chunk.css
│       │   └── main.30b8712a.chunk.css.map
│       ├── js
│       │   ├── 2.224295a1.chunk.js
│       │   ├── 2.224295a1.chunk.js.map
│       │   ├── main.4e95a518.chunk.js
│       │   ├── main.4e95a518.chunk.js.map
│       │   ├── runtime~main.d653cc00.js
│       │   └── runtime~main.d653cc00.js.map
│       └── media
│           ├── eos-lynx-logo-desktop-splash-screen.60561078.svg
│           └── no-tokens.f9a85d50.svg
├── electron-starter.js
└── package.json

@wereii
Copy link

wereii commented Apr 10, 2020

From my comment on this issue with Caprine:

Going thru Electron's code of that aboutPanel (for linux), it does not really seem there is any logic for reading the image from asar files, it goes straight to gdk_pixbuf_new_from_file_at_size (let's say, reading a image file:) ).

So the iconPath option in api.app.setAboutPanelOptions has to be a direct path to file.

This is icon param in electron-util's showAboutWindow.

@wereii
Copy link

wereii commented Apr 10, 2020

One solution is to exempt the icon from being packaged into that app.asar.

Electron-builder has a build setting for that asarUnpack: ["static/Icon.png"].
This setting moves any valid files (it can be a glob: static/*.png) into app.asar.unpacked directory. All other paths to these files (if using path module, so at least path.join) are automatically resolved into that directory.

Take in mind it seems there is a lot of issues around this setting.
EDIT: As said, it's buggy, it indeed unpacks the icon into .unpacked dir but also into the asar, so the paths still resolve into, that assar. See hazardous package mentioned in the issue about problems with this option.

@mquevill
Copy link
Contributor

Including asarUnpack: ["static/Icon.png"] in package.json seems to work. You can use fixPathForAsarUnpack() from this package to resolve the paths.

See how I implemented this in Caprine: https://github.com/sindresorhus/caprine/pull/1674/files

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

No branches or pull requests

4 participants