mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix AppImage windows not showing the application icon (#6444)
Signed-off-by: Damien Degois <damien@degois.info> Signed-off-by: Damien Degois <damien@degois.info>
This commit is contained in:
parent
c591f08bc4
commit
8bc5856b8c
@ -7,6 +7,7 @@ import { getGlobalOverride } from "../test-utils/get-global-override";
|
|||||||
import applicationInformationInjectable from "./application-information.injectable";
|
import applicationInformationInjectable from "./application-information.injectable";
|
||||||
|
|
||||||
export default getGlobalOverride(applicationInformationInjectable, () => ({
|
export default getGlobalOverride(applicationInformationInjectable, () => ({
|
||||||
|
name: "some-product-name",
|
||||||
productName: "some-product-name",
|
productName: "some-product-name",
|
||||||
version: "6.0.0",
|
version: "6.0.0",
|
||||||
build: {},
|
build: {},
|
||||||
|
|||||||
@ -5,16 +5,16 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import packageJson from "../../../package.json";
|
import packageJson from "../../../package.json";
|
||||||
|
|
||||||
export type ApplicationInformation = Pick<typeof packageJson, "version" | "config" | "productName" | "copyright" | "description"> & {
|
export type ApplicationInformation = Pick<typeof packageJson, "version" | "config" | "productName" | "copyright" | "description" | "name"> & {
|
||||||
build: Partial<typeof packageJson["build"]> & { publish?: unknown[] };
|
build: Partial<typeof packageJson["build"]> & { publish?: unknown[] };
|
||||||
};
|
};
|
||||||
|
|
||||||
const applicationInformationInjectable = getInjectable({
|
const applicationInformationInjectable = getInjectable({
|
||||||
id: "application-information",
|
id: "application-information",
|
||||||
instantiate: (): ApplicationInformation => {
|
instantiate: (): ApplicationInformation => {
|
||||||
const { version, config, productName, build, copyright, description } = packageJson;
|
const { version, config, productName, build, copyright, description, name } = packageJson;
|
||||||
|
|
||||||
return { version, config, productName, build, copyright, description };
|
return { version, config, productName, build, copyright, description, name };
|
||||||
},
|
},
|
||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,6 +9,12 @@ import { BrowserWindow } from "electron";
|
|||||||
import type { ElectronWindow } from "./create-lens-window.injectable";
|
import type { ElectronWindow } from "./create-lens-window.injectable";
|
||||||
import type { RequireExactlyOne } from "type-fest";
|
import type { RequireExactlyOne } from "type-fest";
|
||||||
import openLinkInBrowserInjectable from "../../../../common/utils/open-link-in-browser.injectable";
|
import openLinkInBrowserInjectable from "../../../../common/utils/open-link-in-browser.injectable";
|
||||||
|
import getAbsolutePathInjectable from "../../../../common/path/get-absolute-path.injectable";
|
||||||
|
import lensResourcesDirInjectable from "../../../../common/vars/lens-resources-dir.injectable";
|
||||||
|
import isLinuxInjectable from "../../../../common/vars/is-linux.injectable";
|
||||||
|
import fsInjectable from "../../../../common/fs/fs.injectable";
|
||||||
|
import applicationInformationInjectable from "../../../../common/vars/application-information.injectable";
|
||||||
|
|
||||||
|
|
||||||
export type ElectronWindowTitleBarStyle = "hiddenInset" | "hidden" | "default" | "customButtonsOnHover";
|
export type ElectronWindowTitleBarStyle = "hiddenInset" | "hidden" | "default" | "customButtonsOnHover";
|
||||||
|
|
||||||
@ -45,6 +51,10 @@ const createElectronWindowInjectable = getInjectable({
|
|||||||
instantiate: (di): CreateElectronWindow => {
|
instantiate: (di): CreateElectronWindow => {
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const openLinkInBrowser = di.inject(openLinkInBrowserInjectable);
|
const openLinkInBrowser = di.inject(openLinkInBrowserInjectable);
|
||||||
|
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
|
||||||
|
const lensResourcesDir = di.inject(lensResourcesDirInjectable);
|
||||||
|
const isLinux = di.inject(isLinuxInjectable);
|
||||||
|
const applicationInformation = di.inject(applicationInformationInjectable);
|
||||||
|
|
||||||
return (configuration) => {
|
return (configuration) => {
|
||||||
const applicationWindowState = di.inject(
|
const applicationWindowState = di.inject(
|
||||||
@ -79,6 +89,23 @@ const createElectronWindowInjectable = getInjectable({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (isLinux) {
|
||||||
|
const iconFileName = [
|
||||||
|
getAbsolutePath(lensResourcesDir, `../${applicationInformation.name}.png`),
|
||||||
|
`/usr/share/icons/hicolor/512x512/apps/${applicationInformation.name}.png`,
|
||||||
|
].find(di.inject(fsInjectable).existsSync);
|
||||||
|
|
||||||
|
if (iconFileName != null) {
|
||||||
|
try {
|
||||||
|
browserWindow.setIcon(iconFileName);
|
||||||
|
} catch (err) {
|
||||||
|
logger.warn(`Error while setting window icon ${err}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn(`No suitable icon found for task bar.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
applicationWindowState.manage(browserWindow);
|
applicationWindowState.manage(browserWindow);
|
||||||
|
|
||||||
browserWindow
|
browserWindow
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user