Skip to content

Commit cda2080

Browse files
committed
fix: tray menu does not appear in production builds on linux and windows
We had two places in the tray menu code where we were assuming the macOS file layout for production builds (which is somewhat different from that on linux and windows)
1 parent c9ee70d commit cda2080

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

Diff for: plugins/plugin-codeflare/src/tray/icons.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ import gettingStarted from "@kui-shell/client/icons/png/gettingStartedTemplate.p
2626

2727
import { join } from "path"
2828

29-
const iconHome = process.env.CODEFLARE_HEADLESS || join(process.argv0, "../../Resources/app/dist/headless")
29+
function resources() {
30+
return process.platform === "darwin" ? join(process.argv0, "../../Resources") : join(process.argv0, "../resources")
31+
}
32+
33+
export function iconHome() {
34+
return process.env.CODEFLARE_HEADLESS || join(resources(), "app/dist/headless")
35+
}
3036

3137
/** Resize and templatize, so that the icon morphs with platform color themes */
3238
function iconFor(filepath: string) {
33-
return join(iconHome, filepath)
39+
return join(iconHome(), filepath)
3440
}
3541

3642
export const rayIcon = iconFor(ray)

Diff for: plugins/plugin-codeflare/src/tray/main.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { join } from "path"
1818
import { CreateWindowFunction } from "@kui-shell/core"
1919

20+
import { iconHome } from "./icons"
2021
import buildContextMenu from "./menus"
2122
import { productName } from "@kui-shell/client/config.d/name.json"
2223

@@ -87,18 +88,13 @@ export default async function main(createWindow: CreateWindowFunction) {
8788
try {
8889
const { Tray } = await import("electron")
8990

90-
const iconHome = process.env.CODEFLARE_HEADLESS || join(process.argv0, "../../Resources/app/dist/headless")
91-
if (iconHome) {
92-
// this forces webpack to include the @2x template images in
93-
// the build
94-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
95-
const fake = "dist/headless/" + icon2x
91+
// this forces webpack to include the @2x template images in
92+
// the build
93+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
94+
const fake = "dist/headless/" + icon2x
9695

97-
tray = new Tray(join(iconHome, icon))
98-
new LiveMenu(tray, createWindow)
99-
} else {
100-
console.error("Cannot register electron tray menu, because CODEFLARE_HEADLESS environment variable is absent")
101-
}
96+
tray = new Tray(join(iconHome(), icon))
97+
new LiveMenu(tray, createWindow)
10298
} catch (err) {
10399
console.error("Error registering electron tray menu", err)
104100
}

0 commit comments

Comments
 (0)