question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linux .deb icon requires packing/making for MacOS

See original GitHub issue
  • Electron-Builder Version: 22.11.11
  • Node Version: v16.15.0
  • Electron Version: v19.0.1
  • Electron Type (current, beta, nightly):current
  • Target: Linux .deb

My electron-builder.config.json looks something like this:

{
  "appId": "com.yourdoamnin.yourapp",
  "directories": {
    "buildResources": "resources"
  },
  "files": [
    "assets/**/*",
    "build/**/*",
    "capacitor.config.*",
    "app/**/*"
  ],
  "linux": {
    "target": ["deb"],
    "category": "Education",
    "icon": "dist/.icon-icns/icon.icns"
  },
  "mac": {
    "target": ["zip"],
    "icon": "assets/appIcon.png"
  },
  "win": {
    "icon": "assets/appIcon.ico"
  }
}

My package.json scripts look like this:

  "scripts": {
    "build": "tsc",
    "electron.start-live": "node ./live-runner.js",
    "electron.start": "npm run build && electron --inspect=5858 ./",
    "electron.pack": "npm run build && electron-builder build -lmw --dir -c ./electron-builder.config.json",
    "electron.make": "npm run build && electron-builder build -l -c ./electron-builder.config.json",
    "postinstall": "electron-builder install-app-deps"
  },

assets/appIcon.png is a valid file.

If I run electron.make, it never generates the .icns file whether I set linux.icon to undefined, "assets/appIcon.png", or "dist/.icon-icns/icon.icns". So when I install the generated .deb file, it is either the blank gear icon or the default electron icon.

However, if I run electon.pack, it will create the .icns file because it builds for mac, then if I set linux.icon to "dist/.icon-icns/icon.icns" and run electron.make again, the installed .deb file will have the correct icon. Why should I have to pack it for mac in order for the linux debian icon to work? This seems like an undesireable workflow.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
burgilcommented, Jun 6, 2022

You are saying to point mac.icon to ./assets/appIcon.png one time, run electron-builder to let it create the ./dist/.icon-icns/icon.icns at least once, move that icon.icns to ./assets/appIcon.icns, then finally change mac.icon and linux.icon to point to the new ./assets/appIcon.icns?

Yes that is what I meant I guess, I just used an online icon generator lol

Any thoughts or insights from someone with more experience (than @burgil and myself)

Haha I agree, I’m not a contributor just trying to help 😃

Building for MacOS will automatically generate the icon.icns

I did not know that, thank you I’ve learned something new 👍

Also, to your point that You cannot use a .png as mac icons, this documentation seems to disagree with you.

Well I see that just now, I guess that I didn’t know they were generating that icons in that case,

I would like to point out that when I made an app for Mac once using xCode it did not let me put a png as the favicon, and I had to generate the .icns manually using a terminal command that was only available in mac os to convert a png to icns, did that years ago

So why, when building only for Linux, shouldn’t the default be to generate a .icns just as MacOS would, then generate the required Linux icons from that?

Are you building from Windows, Mac or Linux?

this article talks about cross platform builds and how you can only build from mac to windows but not vice versa I think…

image

https://www.electron.build/multi-platform-build

Free public Electron Build Service is used to build Electron app for Linux on Windows. On macOS/Linux you can build Electron app for Windows locally, except Appx for Windows Store (in the future (feel free to file issue) electron-build-service will support Appx target).

Anywho good luck 😄

0reactions
troywweber7commented, Jun 6, 2022

@burgil yep, that’s my conclusion as well.

But just to be super clear for anyone who comes across this issue, while this extra information about building for MacOS is helpful, it is not relevant to my original question.

On Linux you can build the unpacked MacOS files with --dir, which generates the .icns, which the build for Linux can then use to generate its PNG files. But if you want to generate only for Linux, there is no option to leave out the MacOS dir build and generate all the necessary Linux icons automatically from a single PNG.

There are workarounds, but obviously they’re not an ideal workflow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linux .deb icon requires packing/making for MacOS - GitHub
A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box - Linux...
Read more >
Icons - electron-builder
Linux icon set will be generated automatically based on the macOS icns file or common icon.png . Or you can put them into...
Read more >
How do I set icon for Electron app on Linux(Ubuntu, ...)?
I have successfully set icon for my electron app on MacOS and Windows OS with the icon file in the build folder, configuration...
Read more >
Iconset - Best Icons Organizer & Manager for Mac and Windows
Best SVG vector icons, icon sets & icon packs organizer and manager app for designers, developers and teams. Works on both macOS and...
Read more >
How to Make Ubuntu Look Like macOS in 5 Easy Steps
Don't agree? See how you can give your Ubuntu Linux a macOS makeover. ... You'll need it to change the themes and icons....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found