Electron-builder: No app icon (deb installation)

Created on 2 Mar 2018  路  5Comments  路  Source: electron-userland/electron-builder


  • Version: 20.2.0

  • Target: Linux (debian based distro)


package.json

"linux": {
      "category": "AudioVideo",
      "packageCategory": "AudioVideo",
      "synopsis": "...",
      "icon": "./build/icons",
      "target": [   {
          "target": "deb",
          "arch": [  "x64", "ia32" ]
        } ],
      "maintainer": "...",
      "desktop": {
        "Encoding": "UTF-8"
      }

The ./build/icons folder contains 10 png files named according to the image size: 16x16.png to 1024x1024.png

.desktop file produced
[Desktop Entry] Name=appname Comment=... Exec="/opt/appname/appname" %U Terminal=false Type=Application Icon=appname Encoding=UTF-8 Categories=AudioVideo;

The generated .deb file have the following structure inside:

...
[usr]
----[share]
---------[icons]
-------------[hicolor]
------------------[16x16]
------------------------[apps]
---------------------------- appname.png
                                  ...
------------------ [1024x1024]
------------------------[apps]
---------------------------- appname.png

No app icon on any shortcut.

If I want to have an app icon I have to use the following:
1- add an icon file to root directory and specify it on the ExtraFiles entry of the package.json
2- change the linux.desktop key on the package.json to something like

"desktop": {
   Icon="/opt/appname/iconfilename.png"
   ...
}

What's the correct way to automate app icon creation with the electron builder?

bug

Most helpful comment

I listed the file permissions on the ./build/icons folder and notice that the file permissions are wrong (-rwxrwx---). The electron builder copied the files without changing their permissions so that was my fault that the system cannot read the icons!

I changed all the .png icon file permissions inside the icons folder with the command
sudo chmod 0644 *
and the all files are copied correctly and the system can now read the icon.

I will close this issue, but before that, I will leave the following warning to other users with the same issue:

### If you use custom png icons inside a folder (like ./build/icons/24x24.png) make sure that the files _have the correct permissions._ You can change that with the command sudo chmod 0644 *

All 5 comments

I think I found the problem...
If you listing the files inside the usr/share/icons/hicolor/XX-XX/apps/ folder you see that the files are copied without other read permissions

ls icons

Also, they are copied with execute permissions!!

I change all the icon file permissions with the following command:
sudo chmod 0644 filename.png
and the system can now read the icons!

The electron builder copies the ExtraFiles with the following permissions -rwxrwxr-x so it can be read by the system if I manually specify the path to the icon as I said on the first post.

So until any proper fix, I suggest you use that method if you want icons on your deb installations

I made another test...
This time I use the .ICNS file to generate the icon files

"linux": {
      "icon": "./build/icon.icns",
..
}

The electron builder copy all the files to the correct folder with the proper read permissions
(-rw-rw-r-- the group permissions to write aren't needed but that doesn't matter for this case)
So this way it's a better alternative to add the icons to your app

I listed the file permissions on the ./build/icons folder and notice that the file permissions are wrong (-rwxrwx---). The electron builder copied the files without changing their permissions so that was my fault that the system cannot read the icons!

I changed all the .png icon file permissions inside the icons folder with the command
sudo chmod 0644 *
and the all files are copied correctly and the system can now read the icon.

I will close this issue, but before that, I will leave the following warning to other users with the same issue:

### If you use custom png icons inside a folder (like ./build/icons/24x24.png) make sure that the files _have the correct permissions._ You can change that with the command sudo chmod 0644 *

@samuelcarreira You are hero. Thanks a lot.

Fixed by adding "icon": "build/icon.icns", to the Linux section ass seen here https://github.com/szTheory/exifcleaner/pull/99/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexstrat picture alexstrat  路  3Comments

xingoxu picture xingoxu  路  3Comments

iklemm picture iklemm  路  3Comments

philcockfield picture philcockfield  路  3Comments

omarkilani picture omarkilani  路  3Comments