Skip to content

fix: missing app icon for AppImage on Linux #2190

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

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '../common/protocol/ide-updater';
import { IsTempSketch } from '../node/is-temp-sketch';
import { ElectronArduino } from './electron-arduino';
import { FixAppImageIcon } from './fix-app-image-icon';
import { IDEUpdaterImpl } from './ide-updater/ide-updater-impl';
import { ElectronMainApplication } from './theia/electron-main-application';
import { ElectronMainWindowServiceImpl } from './theia/electron-main-window-service';
Expand Down Expand Up @@ -58,4 +59,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
// eclipse-theia/theia#12500
bind(TheiaMainApiFixFalsyHandlerId).toSelf().inSingletonScope();
rebind(TheiaMainApi).toService(TheiaMainApiFixFalsyHandlerId);

// https://github.com/arduino/arduino-ide/issues/131
bind(FixAppImageIcon).toSelf().inSingletonScope();
bind(ElectronMainApplicationContribution).toService(FixAppImageIcon);
});
31 changes: 31 additions & 0 deletions arduino-ide-extension/src/electron-main/fix-app-image-icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { environment } from '@theia/application-package/lib/environment';
import { isOSX, isWindows } from '@theia/core/lib/common/os';
import {
ElectronMainApplication,
ElectronMainApplicationContribution,
} from '@theia/core/lib/electron-main/electron-main-application';
import { injectable } from '@theia/core/shared/inversify';
import { join } from 'node:path';

// Fixes no application icon for the AppImage on Linux (https://github.com/arduino/arduino-ide/issues/131)
// The fix was based on https://github.com/eclipse-theia/theia-blueprint/pull/180.
// Upstream: https://github.com/electron-userland/electron-builder/issues/4617
@injectable()
export class FixAppImageIcon implements ElectronMainApplicationContribution {
onStart(application: ElectronMainApplication): void {
if (isOSX || isWindows || environment.electron.isDevMode()) {
return;
}
const windowOptions = application.config.electron.windowOptions;
if (windowOptions && windowOptions.icon === undefined) {
windowOptions.icon = join(
__dirname,
'..',
'..',
'resources',
'icons',
'512x512.png'
);
}
}
}
1 change: 1 addition & 0 deletions electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"arduino-ide-electron-main.js",
"src-gen",
"lib",
"resources/icons/512x512.png",
"!**node_modules/**"
],
"extraResources": [
Expand Down