From 73c6633a31c462554dd6928910063ab99e31f833 Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sat, 4 May 2024 19:37:22 -0400 Subject: [PATCH 01/20] Updated Vesktop settings to include an option to select a tray icon. --- src/main/ipc.ts | 14 +++++++++++++ src/main/mainWindow.ts | 20 +++++++++++++++---- src/preload/VesktopNative.ts | 3 ++- src/renderer/components/settings/Settings.tsx | 4 +++- src/shared/IpcEvents.ts | 1 + src/shared/settings.d.ts | 1 + 6 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/main/ipc.ts b/src/main/ipc.ts index e0bf131..46afde5 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -121,6 +121,20 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => { return dir; }); +handle(IpcEvents.SELECT_TRAY_ICON, async () => { + const res = await dialog.showOpenDialog(mainWin!, { + properties: ["openFile"], + filters: [{name: "Image", extensions: ["png", "jpg"]}] + }); + if (!res.filePaths.length) return "cancelled"; + + const dir = res.filePaths[0]; + const image = nativeImage.createFromPath(dir); + if(image.isEmpty()) return "invalid"; + + return dir; +}); + handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count)); handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => { diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 7e0afde..16c5d77 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -12,6 +12,7 @@ import { Menu, MenuItemConstructorOptions, nativeTheme, + nativeImage, Tray } from "electron"; import { rm } from "fs/promises"; @@ -20,7 +21,7 @@ import { IpcEvents } from "shared/IpcEvents"; import { isTruthy } from "shared/utils/guards"; import { once } from "shared/utils/once"; import type { SettingsStore } from "shared/utils/SettingsStore"; - +import { existsSync } from "fs"; import { ICON_PATH } from "../shared/paths"; import { createAboutWindow } from "./about"; import { initArRPC } from "./arrpc"; @@ -120,8 +121,15 @@ function initTray(win: BrowserWindow) { } } ]); - - tray = new Tray(ICON_PATH); + if (Settings.store.trayIconPath) { + const trayImage = nativeImage.createFromPath(Settings.store.trayIconPath); + if (!trayImage.isEmpty()) tray = new Tray(trayImage.resize({width: 32, height: 32})); + else tray = new Tray(ICON_PATH); + } + else { + tray = new Tray(ICON_PATH); + } + tray.setToolTip("Vesktop"); tray.setContextMenu(trayMenu); tray.on("click", onTrayClick); @@ -273,7 +281,7 @@ function getWindowBoundsOptions(): BrowserWindowConstructorOptions { options.x = x; options.y = y; } - + if (!Settings.store.disableMinSize) { options.minWidth = MIN_WIDTH; options.minHeight = MIN_HEIGHT; @@ -328,6 +336,10 @@ function initSettingsListeners(win: BrowserWindow) { if (enable) initTray(win); else tray?.destroy(); }); + addSettingsListener("trayIconPath", _ => { + tray?.destroy(); + initTray(win); + }); addSettingsListener("disableMinSize", disable => { if (disable) { // 0 no work diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index 184b095..467bfb6 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -33,7 +33,8 @@ export const VesktopNative = { }, fileManager: { showItemInFolder: (path: string) => invoke(IpcEvents.SHOW_ITEM_IN_FOLDER, path), - selectVencordDir: () => invoke>(IpcEvents.SELECT_VENCORD_DIR) + selectVencordDir: () => invoke>(IpcEvents.SELECT_VENCORD_DIR), + selectTrayIcon: () => invoke>(IpcEvents.SELECT_TRAY_ICON) }, settings: { get: () => sendSync(IpcEvents.GET_SETTINGS), diff --git a/src/renderer/components/settings/Settings.tsx b/src/renderer/components/settings/Settings.tsx index d6de13c..3127308 100644 --- a/src/renderer/components/settings/Settings.tsx +++ b/src/renderer/components/settings/Settings.tsx @@ -15,6 +15,7 @@ import { AutoStartToggle } from "./AutoStartToggle"; import { DiscordBranchPicker } from "./DiscordBranchPicker"; import { NotificationBadgeToggle } from "./NotificationBadgeToggle"; import { VencordLocationPicker } from "./VencordLocationPicker"; +import { TrayIconImagePicker } from "./TrayIconImagePicker"; import { WindowsTransparencyControls } from "./WindowsTransparencyControls"; interface BooleanSetting { @@ -126,7 +127,8 @@ const SettingsOptions: Record> defaultValue: false } ], - "Vencord Location": [VencordLocationPicker] + "Tray Icon Image": [TrayIconImagePicker], + "Vencord Location": [VencordLocationPicker], }; function SettingsSections() { diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts index df64403..407403b 100644 --- a/src/shared/IpcEvents.ts +++ b/src/shared/IpcEvents.ts @@ -24,6 +24,7 @@ export const enum IpcEvents { SET_SETTINGS = "VCD_SET_SETTINGS", SELECT_VENCORD_DIR = "VCD_SELECT_VENCORD_DIR", + SELECT_TRAY_ICON = "VCD_SELECT_TRAY_ICON", UPDATER_GET_DATA = "VCD_UPDATER_GET_DATA", UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD", diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts index 7f6e74a..c9d00ee 100644 --- a/src/shared/settings.d.ts +++ b/src/shared/settings.d.ts @@ -24,6 +24,7 @@ export interface Settings { /** @deprecated use customTitleBar */ discordWindowsTitleBar?: boolean; customTitleBar?: boolean; + trayIconPath?: string checkUpdates?: boolean; From 74bc6d8e5e275aa2aa1fe320fe3b158c2f50327f Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sat, 4 May 2024 19:55:37 -0400 Subject: [PATCH 02/20] Removed unnecessary import --- src/main/mainWindow.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 16c5d77..069a116 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -21,7 +21,6 @@ import { IpcEvents } from "shared/IpcEvents"; import { isTruthy } from "shared/utils/guards"; import { once } from "shared/utils/once"; import type { SettingsStore } from "shared/utils/SettingsStore"; -import { existsSync } from "fs"; import { ICON_PATH } from "../shared/paths"; import { createAboutWindow } from "./about"; import { initArRPC } from "./arrpc"; From 0f1fd8485497e3798899829428a7080b4baebf7d Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sat, 4 May 2024 20:04:46 -0400 Subject: [PATCH 03/20] Add semicolon --- src/shared/settings.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts index c9d00ee..46c2253 100644 --- a/src/shared/settings.d.ts +++ b/src/shared/settings.d.ts @@ -24,7 +24,7 @@ export interface Settings { /** @deprecated use customTitleBar */ discordWindowsTitleBar?: boolean; customTitleBar?: boolean; - trayIconPath?: string + trayIconPath?: string; checkUpdates?: boolean; From 7dacbb7ddaae87ffe5fc4f1d31a29d973c471a90 Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sat, 4 May 2024 20:33:09 -0400 Subject: [PATCH 04/20] Added setting component for tray icon select --- .../settings/TrayIconImagePicker.tsx | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/renderer/components/settings/TrayIconImagePicker.tsx diff --git a/src/renderer/components/settings/TrayIconImagePicker.tsx b/src/renderer/components/settings/TrayIconImagePicker.tsx new file mode 100644 index 0000000..352e51e --- /dev/null +++ b/src/renderer/components/settings/TrayIconImagePicker.tsx @@ -0,0 +1,62 @@ +/* + * SPDX-License-Identifier: GPL-3.0 + * Vesktop, a desktop app aiming to give you a snappier Discord Experience + * Copyright (c) 2023 Vendicated and Vencord contributors + */ + +import { Button, Forms, Toasts } from "@vencord/types/webpack/common"; + +import { SettingsComponent } from "./Settings"; + +export const TrayIconImagePicker: SettingsComponent = ({ settings }) => { + return ( + <> + + Tray icon is currently {" "} + {settings.trayIconPath ? ( + { + e.preventDefault(); + VesktopNative.fileManager.showItemInFolder(settings.trayIconPath!); + }} + > + {settings.trayIconPath} + + ) : ( + "the default location" + )} + +
+ + +
+ + ); +}; From af04134c37d7092e124090c3e5a4c85bc11f4a8c Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sat, 4 May 2024 20:33:43 -0400 Subject: [PATCH 05/20] simplified logic for selecting tray icon on tray init --- src/main/mainWindow.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 069a116..58b580a 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -120,13 +120,10 @@ function initTray(win: BrowserWindow) { } } ]); + tray = new Tray(ICON_PATH); if (Settings.store.trayIconPath) { const trayImage = nativeImage.createFromPath(Settings.store.trayIconPath); - if (!trayImage.isEmpty()) tray = new Tray(trayImage.resize({width: 32, height: 32})); - else tray = new Tray(ICON_PATH); - } - else { - tray = new Tray(ICON_PATH); + if (!trayImage.isEmpty()) tray.setImage(trayImage.resize({width: 32, height: 32})); } tray.setToolTip("Vesktop"); From 02bd04e3a595f374d527468685eb7be7e6b4d82f Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sun, 5 May 2024 14:24:13 -0400 Subject: [PATCH 06/20] moved tray icon option from Vesktop settings to tray context menu item --- src/main/mainWindow.ts | 62 ++++++++++++++++--- src/renderer/components/settings/Settings.tsx | 3 +- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 58b580a..fc04402 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -102,6 +102,21 @@ function initTray(win: BrowserWindow) { await clearData(win); } }, + { + label: "Change Tray Icon", + async click() { + await setTrayIcon(); + /* + switch (choice) { + case "invalid": + return; + case "cancelled": + return; + } + Settings.store.trayIconPath = choice; + */ + } + }, { type: "separator" }, @@ -120,12 +135,7 @@ function initTray(win: BrowserWindow) { } } ]); - tray = new Tray(ICON_PATH); - if (Settings.store.trayIconPath) { - const trayImage = nativeImage.createFromPath(Settings.store.trayIconPath); - if (!trayImage.isEmpty()) tray.setImage(trayImage.resize({width: 32, height: 32})); - } - + tray = new Tray(getTrayIcon()); tray.setToolTip("Vesktop"); tray.setContextMenu(trayMenu); tray.on("click", onTrayClick); @@ -277,7 +287,7 @@ function getWindowBoundsOptions(): BrowserWindowConstructorOptions { options.x = x; options.y = y; } - + if (!Settings.store.disableMinSize) { options.minWidth = MIN_WIDTH; options.minHeight = MIN_HEIGHT; @@ -486,3 +496,41 @@ export async function createWindows() { initArRPC(); } + +export function getTrayIcon(): string { + if (Settings.store.trayIconPath) { + const trayImage = nativeImage.createFromPath(Settings.store.trayIconPath); + if (!trayImage.isEmpty()) return Settings.store.trayIconPath; + } + + return ICON_PATH; +} + +async function setTrayIcon(): Promise { + const userSelection = await dialog.showMessageBox(mainWin!, { + type: "question", + title: "Change/Reset tray icon", + message: "Would you like to change or reset the Vesktop tray icon?", + buttons: ["Change", "Reset"], + defaultId: 0, + cancelId: 2, + icon: getTrayIcon() + }); + if (userSelection.response == 2) return; + if (userSelection.response == 1) { + Settings.store.trayIconPath = void 0; + return; + } + const res = await dialog.showOpenDialog(mainWin!, { + properties: ["openFile"], + filters: [{ name: "Image", extensions: ["png", "jpg"] }], + defaultPath: getTrayIcon() + }); + if (!res.filePaths.length) return; + + const dir = res.filePaths[0]; + const image = nativeImage.createFromPath(dir); + if (image.isEmpty()) return; + + Settings.store.trayIconPath = dir; +} diff --git a/src/renderer/components/settings/Settings.tsx b/src/renderer/components/settings/Settings.tsx index 3127308..c162c26 100644 --- a/src/renderer/components/settings/Settings.tsx +++ b/src/renderer/components/settings/Settings.tsx @@ -127,8 +127,7 @@ const SettingsOptions: Record> defaultValue: false } ], - "Tray Icon Image": [TrayIconImagePicker], - "Vencord Location": [VencordLocationPicker], + "Tray Icon Image": [TrayIconImagePicker] }; function SettingsSections() { From a3f38ce2059e7a9c95274bbdab9d19619e2937da Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sun, 5 May 2024 14:25:24 -0400 Subject: [PATCH 07/20] removed deprecated references to tray icon setting --- src/main/ipc.ts | 16 +---- src/preload/VesktopNative.ts | 3 +- .../settings/TrayIconImagePicker.tsx | 62 ------------------- src/shared/IpcEvents.ts | 1 - 4 files changed, 2 insertions(+), 80 deletions(-) delete mode 100644 src/renderer/components/settings/TrayIconImagePicker.tsx diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 46afde5..8fad6b0 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -18,7 +18,7 @@ import { IpcEvents } from "../shared/IpcEvents"; import { setBadgeCount } from "./appBadge"; import { autoStart } from "./autoStart"; import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; -import { mainWin } from "./mainWindow"; +import { mainWin, getTrayIcon } from "./mainWindow"; import { Settings } from "./settings"; import { handle, handleSync } from "./utils/ipcWrappers"; import { PopoutWindows } from "./utils/popout"; @@ -121,20 +121,6 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => { return dir; }); -handle(IpcEvents.SELECT_TRAY_ICON, async () => { - const res = await dialog.showOpenDialog(mainWin!, { - properties: ["openFile"], - filters: [{name: "Image", extensions: ["png", "jpg"]}] - }); - if (!res.filePaths.length) return "cancelled"; - - const dir = res.filePaths[0]; - const image = nativeImage.createFromPath(dir); - if(image.isEmpty()) return "invalid"; - - return dir; -}); - handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count)); handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => { diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index 467bfb6..184b095 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -33,8 +33,7 @@ export const VesktopNative = { }, fileManager: { showItemInFolder: (path: string) => invoke(IpcEvents.SHOW_ITEM_IN_FOLDER, path), - selectVencordDir: () => invoke>(IpcEvents.SELECT_VENCORD_DIR), - selectTrayIcon: () => invoke>(IpcEvents.SELECT_TRAY_ICON) + selectVencordDir: () => invoke>(IpcEvents.SELECT_VENCORD_DIR) }, settings: { get: () => sendSync(IpcEvents.GET_SETTINGS), diff --git a/src/renderer/components/settings/TrayIconImagePicker.tsx b/src/renderer/components/settings/TrayIconImagePicker.tsx deleted file mode 100644 index 352e51e..0000000 --- a/src/renderer/components/settings/TrayIconImagePicker.tsx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SPDX-License-Identifier: GPL-3.0 - * Vesktop, a desktop app aiming to give you a snappier Discord Experience - * Copyright (c) 2023 Vendicated and Vencord contributors - */ - -import { Button, Forms, Toasts } from "@vencord/types/webpack/common"; - -import { SettingsComponent } from "./Settings"; - -export const TrayIconImagePicker: SettingsComponent = ({ settings }) => { - return ( - <> - - Tray icon is currently {" "} - {settings.trayIconPath ? ( - { - e.preventDefault(); - VesktopNative.fileManager.showItemInFolder(settings.trayIconPath!); - }} - > - {settings.trayIconPath} - - ) : ( - "the default location" - )} - -
- - -
- - ); -}; diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts index 407403b..df64403 100644 --- a/src/shared/IpcEvents.ts +++ b/src/shared/IpcEvents.ts @@ -24,7 +24,6 @@ export const enum IpcEvents { SET_SETTINGS = "VCD_SET_SETTINGS", SELECT_VENCORD_DIR = "VCD_SELECT_VENCORD_DIR", - SELECT_TRAY_ICON = "VCD_SELECT_TRAY_ICON", UPDATER_GET_DATA = "VCD_UPDATER_GET_DATA", UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD", From 0a654fec802fa8b3cf505baa38d6129bd19ac00f Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sun, 5 May 2024 14:27:11 -0400 Subject: [PATCH 08/20] re-add vencord location setting --- src/renderer/components/settings/Settings.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/renderer/components/settings/Settings.tsx b/src/renderer/components/settings/Settings.tsx index c162c26..d6de13c 100644 --- a/src/renderer/components/settings/Settings.tsx +++ b/src/renderer/components/settings/Settings.tsx @@ -15,7 +15,6 @@ import { AutoStartToggle } from "./AutoStartToggle"; import { DiscordBranchPicker } from "./DiscordBranchPicker"; import { NotificationBadgeToggle } from "./NotificationBadgeToggle"; import { VencordLocationPicker } from "./VencordLocationPicker"; -import { TrayIconImagePicker } from "./TrayIconImagePicker"; import { WindowsTransparencyControls } from "./WindowsTransparencyControls"; interface BooleanSetting { @@ -127,7 +126,7 @@ const SettingsOptions: Record> defaultValue: false } ], - "Tray Icon Image": [TrayIconImagePicker] + "Vencord Location": [VencordLocationPicker] }; function SettingsSections() { From 706748f5a59342d1014726b0e41c2648e49e2964 Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sun, 5 May 2024 14:30:36 -0400 Subject: [PATCH 09/20] cleanup --- src/main/ipc.ts | 2 +- src/main/mainWindow.ts | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 8fad6b0..e0bf131 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -18,7 +18,7 @@ import { IpcEvents } from "../shared/IpcEvents"; import { setBadgeCount } from "./appBadge"; import { autoStart } from "./autoStart"; import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; -import { mainWin, getTrayIcon } from "./mainWindow"; +import { mainWin } from "./mainWindow"; import { Settings } from "./settings"; import { handle, handleSync } from "./utils/ipcWrappers"; import { PopoutWindows } from "./utils/popout"; diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index fc04402..b5b74bf 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -106,15 +106,6 @@ function initTray(win: BrowserWindow) { label: "Change Tray Icon", async click() { await setTrayIcon(); - /* - switch (choice) { - case "invalid": - return; - case "cancelled": - return; - } - Settings.store.trayIconPath = choice; - */ } }, { From a85ac17bef8841a4b54bcb53c651b18b6a294a3e Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sun, 5 May 2024 14:52:45 -0400 Subject: [PATCH 10/20] fixed crash if a very large tray image was selected --- src/main/mainWindow.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index b5b74bf..ce625c3 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -126,7 +126,8 @@ function initTray(win: BrowserWindow) { } } ]); - tray = new Tray(getTrayIcon()); + const trayImage = nativeImage.createFromPath(getTrayIcon()).resize({ width: 32, height: 32 }); + tray = new Tray(trayImage); tray.setToolTip("Vesktop"); tray.setContextMenu(trayMenu); tray.on("click", onTrayClick); @@ -493,7 +494,6 @@ export function getTrayIcon(): string { const trayImage = nativeImage.createFromPath(Settings.store.trayIconPath); if (!trayImage.isEmpty()) return Settings.store.trayIconPath; } - return ICON_PATH; } From 73f6a321aab255c85aa6a67477035f616cfcae6e Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Sun, 5 May 2024 19:07:51 -0400 Subject: [PATCH 11/20] fixed pnpm issues --- src/main/mainWindow.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index ce625c3..ddeaa1d 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -11,8 +11,8 @@ import { dialog, Menu, MenuItemConstructorOptions, - nativeTheme, nativeImage, + nativeTheme, Tray } from "electron"; import { rm } from "fs/promises"; @@ -21,6 +21,7 @@ import { IpcEvents } from "shared/IpcEvents"; import { isTruthy } from "shared/utils/guards"; import { once } from "shared/utils/once"; import type { SettingsStore } from "shared/utils/SettingsStore"; + import { ICON_PATH } from "../shared/paths"; import { createAboutWindow } from "./about"; import { initArRPC } from "./arrpc"; @@ -507,8 +508,8 @@ async function setTrayIcon(): Promise { cancelId: 2, icon: getTrayIcon() }); - if (userSelection.response == 2) return; - if (userSelection.response == 1) { + if (userSelection.response === 2) return; + if (userSelection.response === 1) { Settings.store.trayIconPath = void 0; return; } From 7713a46394a4a163bef63cf371e122478fd64092 Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Mon, 6 May 2024 03:10:19 -0400 Subject: [PATCH 12/20] improved tray icon setting UI --- src/main/ipc.ts | 20 +++- src/main/mainWindow.ts | 9 +- src/preload/VesktopNative.ts | 3 + src/renderer/components/settings/Settings.tsx | 11 +- .../settings/TrayIconImagePicker.tsx | 101 ++++++++++-------- src/renderer/components/settings/settings.css | 60 ++++++++++- src/shared/IpcEvents.ts | 2 + 7 files changed, 144 insertions(+), 62 deletions(-) diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 46afde5..5ab45d9 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -12,6 +12,7 @@ import { mkdirSync, readFileSync, watch } from "fs"; import { open, readFile } from "fs/promises"; import { release } from "os"; import { join } from "path"; +import { ICON_PATH } from "shared/paths"; import { debounce } from "shared/utils/debounce"; import { IpcEvents } from "../shared/IpcEvents"; @@ -41,6 +42,19 @@ handleSync( () => process.platform === "win32" && Number(release().split(".").pop()) >= 22621 ); +handleSync(IpcEvents.GET_TRAY_ICON, () => { + try { + if (!Settings.store.trayIconPath) return nativeImage.createFromPath(ICON_PATH).toDataURL(); + + const img = nativeImage.createFromPath(Settings.store.trayIconPath).resize({ width: 64, height: 64 }); + if (img.isEmpty()) return nativeImage.createFromPath(ICON_PATH).toDataURL(); + + return img.toDataURL(); + } catch (error) { + return "no"; + } +}); + handleSync(IpcEvents.AUTOSTART_ENABLED, () => autoStart.isEnabled()); handle(IpcEvents.ENABLE_AUTOSTART, autoStart.enable); handle(IpcEvents.DISABLE_AUTOSTART, autoStart.disable); @@ -124,13 +138,13 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => { handle(IpcEvents.SELECT_TRAY_ICON, async () => { const res = await dialog.showOpenDialog(mainWin!, { properties: ["openFile"], - filters: [{name: "Image", extensions: ["png", "jpg"]}] + filters: [{ name: "Image", extensions: ["png", "jpg"] }] }); if (!res.filePaths.length) return "cancelled"; - + const dir = res.filePaths[0]; const image = nativeImage.createFromPath(dir); - if(image.isEmpty()) return "invalid"; + if (image.isEmpty()) return "invalid"; return dir; }); diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 58b580a..a3e667a 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -11,8 +11,8 @@ import { dialog, Menu, MenuItemConstructorOptions, - nativeTheme, nativeImage, + nativeTheme, Tray } from "electron"; import { rm } from "fs/promises"; @@ -21,6 +21,7 @@ import { IpcEvents } from "shared/IpcEvents"; import { isTruthy } from "shared/utils/guards"; import { once } from "shared/utils/once"; import type { SettingsStore } from "shared/utils/SettingsStore"; + import { ICON_PATH } from "../shared/paths"; import { createAboutWindow } from "./about"; import { initArRPC } from "./arrpc"; @@ -123,9 +124,9 @@ function initTray(win: BrowserWindow) { tray = new Tray(ICON_PATH); if (Settings.store.trayIconPath) { const trayImage = nativeImage.createFromPath(Settings.store.trayIconPath); - if (!trayImage.isEmpty()) tray.setImage(trayImage.resize({width: 32, height: 32})); + if (!trayImage.isEmpty()) tray.setImage(trayImage.resize({ width: 32, height: 32 })); } - + tray.setToolTip("Vesktop"); tray.setContextMenu(trayMenu); tray.on("click", onTrayClick); @@ -277,7 +278,7 @@ function getWindowBoundsOptions(): BrowserWindowConstructorOptions { options.x = x; options.y = y; } - + if (!Settings.store.disableMinSize) { options.minWidth = MIN_WIDTH; options.minHeight = MIN_HEIGHT; diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index 467bfb6..4f5146b 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -57,6 +57,9 @@ export const VesktopNative = { minimize: () => invoke(IpcEvents.MINIMIZE), maximize: () => invoke(IpcEvents.MAXIMIZE) }, + tray: { + getTrayIcon: () => sendSync(IpcEvents.GET_TRAY_ICON) + }, capturer: { getLargeThumbnail: (id: string) => invoke(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id) }, diff --git a/src/renderer/components/settings/Settings.tsx b/src/renderer/components/settings/Settings.tsx index 3127308..5f7479c 100644 --- a/src/renderer/components/settings/Settings.tsx +++ b/src/renderer/components/settings/Settings.tsx @@ -14,8 +14,8 @@ import { isMac, isWindows } from "renderer/utils"; import { AutoStartToggle } from "./AutoStartToggle"; import { DiscordBranchPicker } from "./DiscordBranchPicker"; import { NotificationBadgeToggle } from "./NotificationBadgeToggle"; -import { VencordLocationPicker } from "./VencordLocationPicker"; import { TrayIconImagePicker } from "./TrayIconImagePicker"; +import { VencordLocationPicker } from "./VencordLocationPicker"; import { WindowsTransparencyControls } from "./WindowsTransparencyControls"; interface BooleanSetting { @@ -69,13 +69,6 @@ const SettingsOptions: Record> WindowsTransparencyControls ], Behaviour: [ - { - key: "tray", - title: "Tray Icon", - description: "Add a tray icon for Vesktop", - defaultValue: true, - invisible: () => isMac - }, { key: "minimizeToTray", title: "Minimize to tray", @@ -128,7 +121,7 @@ const SettingsOptions: Record> } ], "Tray Icon Image": [TrayIconImagePicker], - "Vencord Location": [VencordLocationPicker], + "Vencord Location": [VencordLocationPicker] }; function SettingsSections() { diff --git a/src/renderer/components/settings/TrayIconImagePicker.tsx b/src/renderer/components/settings/TrayIconImagePicker.tsx index 352e51e..cf8487a 100644 --- a/src/renderer/components/settings/TrayIconImagePicker.tsx +++ b/src/renderer/components/settings/TrayIconImagePicker.tsx @@ -4,58 +4,69 @@ * Copyright (c) 2023 Vendicated and Vencord contributors */ -import { Button, Forms, Toasts } from "@vencord/types/webpack/common"; +import { Forms, Switch, Toasts } from "@vencord/types/webpack/common"; +import { Settings } from "renderer/settings"; import { SettingsComponent } from "./Settings"; export const TrayIconImagePicker: SettingsComponent = ({ settings }) => { return ( <> - - Tray icon is currently {" "} - {settings.trayIconPath ? ( - { - e.preventDefault(); - VesktopNative.fileManager.showItemInFolder(settings.trayIconPath!); - }} +
+
+ (Settings.store.tray = v)} + note={"Add a tray icon for Vesktop"} > - {settings.trayIconPath} - - ) : ( - "the default location" - )} - -
- - + {"Tray Icon"} + +
+ +
+
+ hello + { + const choice = await VesktopNative.fileManager.selectTrayIcon(); + switch (choice) { + case "cancelled": + return; + case "invalid": + Toasts.show({ + message: "Please select a valid .png or .jpg image!", + id: Toasts.genId(), + type: Toasts.Type.FAILURE + }); + return; + } + settings.trayIconPath = choice; + }} + /> +
+
); diff --git a/src/renderer/components/settings/settings.css b/src/renderer/components/settings/settings.css index d55ff50..fa66db5 100644 --- a/src/renderer/components/settings/settings.css +++ b/src/renderer/components/settings/settings.css @@ -11,4 +11,62 @@ .vcd-settings-title { margin-bottom: 0.5rem; -} \ No newline at end of file +} + +.tray-icon-wrap { + position: relative; + top: 0; + right: 0; +} + +.tray-icon-image { + border-radius: 50%; + position: relative; + top: 0; + right: 0; +} + +.edit-button { + visibility: visible; + display: block; + opacity: 0; + position: absolute; + top: 4px; + left: 4px; +} + +.tray-icon-wrap:hover .tray-icon-image { + transition: 0.3s ease; + background-color: rgb(0, 0, 0) no-repeat; + opacity: 0.25; +} +.tray-icon-wrap:hover .edit-button { + transition: 0.3s ease; + visibility: visible; + opacity: 1; +} + +#tray-setting { + height: 48px; + position: relative; +} +#colLeft { + height: 48px; + display: inline-block; + width: 40%; +} +#colMiddle { + height: 48px; + float: center; + display: inline; + position: relative; + left: 45%; +} +#colRight { + height: 48px; + display: inline; + float: right; + position: absolute; + top: -12px; + right: 0; +} diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts index 407403b..eb1910a 100644 --- a/src/shared/IpcEvents.ts +++ b/src/shared/IpcEvents.ts @@ -24,7 +24,9 @@ export const enum IpcEvents { SET_SETTINGS = "VCD_SET_SETTINGS", SELECT_VENCORD_DIR = "VCD_SELECT_VENCORD_DIR", + SELECT_TRAY_ICON = "VCD_SELECT_TRAY_ICON", + GET_TRAY_ICON = "VCD_GET_TRAY_ICON", UPDATER_GET_DATA = "VCD_UPDATER_GET_DATA", UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD", From a0fc191ed95643088f689407856386282d9ce577 Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Mon, 6 May 2024 03:19:10 -0400 Subject: [PATCH 13/20] fixed formatting, remove unnecssary code --- src/main/ipc.ts | 12 ++++-------- src/renderer/components/settings/settings.css | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 5ab45d9..806dbdf 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -43,16 +43,12 @@ handleSync( ); handleSync(IpcEvents.GET_TRAY_ICON, () => { - try { - if (!Settings.store.trayIconPath) return nativeImage.createFromPath(ICON_PATH).toDataURL(); + if (!Settings.store.trayIconPath) return nativeImage.createFromPath(ICON_PATH).toDataURL(); - const img = nativeImage.createFromPath(Settings.store.trayIconPath).resize({ width: 64, height: 64 }); - if (img.isEmpty()) return nativeImage.createFromPath(ICON_PATH).toDataURL(); + const img = nativeImage.createFromPath(Settings.store.trayIconPath).resize({ width: 64, height: 64 }); + if (img.isEmpty()) return nativeImage.createFromPath(ICON_PATH).toDataURL(); - return img.toDataURL(); - } catch (error) { - return "no"; - } + return img.toDataURL(); }); handleSync(IpcEvents.AUTOSTART_ENABLED, () => autoStart.isEnabled()); diff --git a/src/renderer/components/settings/settings.css b/src/renderer/components/settings/settings.css index fa66db5..c145f17 100644 --- a/src/renderer/components/settings/settings.css +++ b/src/renderer/components/settings/settings.css @@ -58,7 +58,7 @@ #colMiddle { height: 48px; float: center; - display: inline; + display: inline-block; position: relative; left: 45%; } From 37c32591718e1ac560e9c512489f89bdd4b46a61 Mon Sep 17 00:00:00 2001 From: MrGarlic1 <61215937+MrGarlic1@users.noreply.github.com> Date: Mon, 6 May 2024 11:48:05 -0400 Subject: [PATCH 14/20] fixed macos tray display bugs --- src/main/mainWindow.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index a3e667a..d4add81 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -121,10 +121,14 @@ function initTray(win: BrowserWindow) { } } ]); - tray = new Tray(ICON_PATH); - if (Settings.store.trayIconPath) { - const trayImage = nativeImage.createFromPath(Settings.store.trayIconPath); - if (!trayImage.isEmpty()) tray.setImage(trayImage.resize({ width: 32, height: 32 })); + var trayImage = nativeImage.createFromPath(ICON_PATH); + if (Settings.store.trayIconPath) trayImage = nativeImage.createFromPath(Settings.store.trayIconPath); + if (trayImage.isEmpty()) trayImage = nativeImage.createFromPath(ICON_PATH); + + if (process.platform === "darwin") { + tray = new Tray(trayImage.resize({ width: 16, height: 16 })); + } else { + tray = new Tray(trayImage.resize({ width: 32, height: 32 })); } tray.setToolTip("Vesktop"); @@ -433,7 +437,7 @@ function createMainWindow() { if (Settings.store.staticTitle) win.on("page-title-updated", e => e.preventDefault()); initWindowBoundsListeners(win); - if (!isDeckGameMode && (Settings.store.tray ?? true) && process.platform !== "darwin") initTray(win); + if (!isDeckGameMode && (Settings.store.tray ?? true)) initTray(win); initMenuBar(win); makeLinksOpenExternally(win); initSettingsListeners(win); From 468a97a2fb55bb7bdb0a5358b6a7beb83d07a35d Mon Sep 17 00:00:00 2001 From: MrGarlic1 <61215937+MrGarlic1@users.noreply.github.com> Date: Mon, 6 May 2024 21:36:42 -0400 Subject: [PATCH 15/20] add edit icon --- static/pencil-edit-icon.svg | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 static/pencil-edit-icon.svg diff --git a/static/pencil-edit-icon.svg b/static/pencil-edit-icon.svg new file mode 100644 index 0000000..6288a63 --- /dev/null +++ b/static/pencil-edit-icon.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file From 921e15b5a653c8015a0c13afac8d4cacc0a7c56b Mon Sep 17 00:00:00 2001 From: MrGarlic1 <61215937+MrGarlic1@users.noreply.github.com> Date: Mon, 6 May 2024 22:39:35 -0400 Subject: [PATCH 16/20] Add files via upload From d664a483bbd88fbb93ad9b70aa4dbf071c03d13e Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Mon, 6 May 2024 22:41:22 -0400 Subject: [PATCH 17/20] added static icon link, improved tray settings css --- .../settings/TrayIconImagePicker.tsx | 70 +++++++++---------- src/renderer/components/settings/settings.css | 59 +++++++--------- 2 files changed, 62 insertions(+), 67 deletions(-) diff --git a/src/renderer/components/settings/TrayIconImagePicker.tsx b/src/renderer/components/settings/TrayIconImagePicker.tsx index cf8487a..cfdfe55 100644 --- a/src/renderer/components/settings/TrayIconImagePicker.tsx +++ b/src/renderer/components/settings/TrayIconImagePicker.tsx @@ -6,24 +6,24 @@ import { Forms, Switch, Toasts } from "@vencord/types/webpack/common"; import { Settings } from "renderer/settings"; - +import { STATIC_DIR } from "shared/paths"; import { SettingsComponent } from "./Settings"; export const TrayIconImagePicker: SettingsComponent = ({ settings }) => { return ( <> -
-
+
+
(Settings.store.tray = v)} note={"Add a tray icon for Vesktop"} > - {"Tray Icon"} + Tray Icon
-
+ -
-
- hello - { - const choice = await VesktopNative.fileManager.selectTrayIcon(); - switch (choice) { - case "cancelled": - return; - case "invalid": - Toasts.show({ - message: "Please select a valid .png or .jpg image!", - id: Toasts.genId(), - type: Toasts.Type.FAILURE - }); - return; - } - settings.trayIconPath = choice; - }} - /> -
+
+ hello + { + const choice = await VesktopNative.fileManager.selectTrayIcon(); + switch (choice) { + case "cancelled": + return; + case "invalid": + Toasts.show({ + message: "Please select a valid .png or .jpg image!", + id: Toasts.genId(), + type: Toasts.Type.FAILURE + }); + return; + } + settings.trayIconPath = choice; + }} + />
diff --git a/src/renderer/components/settings/settings.css b/src/renderer/components/settings/settings.css index c145f17..23f0191 100644 --- a/src/renderer/components/settings/settings.css +++ b/src/renderer/components/settings/settings.css @@ -13,20 +13,40 @@ margin-bottom: 0.5rem; } -.tray-icon-wrap { +#vcd-tray-setting { + display: flex; + justify-content: space-between; + align-items: center; + flex-wrap: nowrap; + +} +.vcd-tray-setting-switch { + flex-grow: 1; + align-self: flex-start; + margin-right: 20rem; +} +.vcd-tray-setting-reset { + align-self: right; position: relative; - top: 0; - right: 0; + margin-left: auto; + margin-right: 1em; + bottom: 24px; } -.tray-icon-image { +.vcd-tray-icon-wrap { + position: relative; + align-self: right; + bottom: 24px; +} + +.vcd-tray-icon-image { border-radius: 50%; position: relative; top: 0; right: 0; } -.edit-button { +.vcd-edit-button { visibility: visible; display: block; opacity: 0; @@ -35,38 +55,13 @@ left: 4px; } -.tray-icon-wrap:hover .tray-icon-image { +.vcd-tray-icon-wrap:hover .vcd-tray-icon-image { transition: 0.3s ease; background-color: rgb(0, 0, 0) no-repeat; opacity: 0.25; } -.tray-icon-wrap:hover .edit-button { +.vcd-tray-icon-wrap:hover .vcd-edit-button { transition: 0.3s ease; visibility: visible; opacity: 1; } - -#tray-setting { - height: 48px; - position: relative; -} -#colLeft { - height: 48px; - display: inline-block; - width: 40%; -} -#colMiddle { - height: 48px; - float: center; - display: inline-block; - position: relative; - left: 45%; -} -#colRight { - height: 48px; - display: inline; - float: right; - position: absolute; - top: -12px; - right: 0; -} From c0c46bb1bbd505520e70a3ea117c99bb65a11315 Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Mon, 6 May 2024 22:47:09 -0400 Subject: [PATCH 18/20] fixed import order --- src/renderer/components/settings/TrayIconImagePicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/components/settings/TrayIconImagePicker.tsx b/src/renderer/components/settings/TrayIconImagePicker.tsx index cfdfe55..a8cb52b 100644 --- a/src/renderer/components/settings/TrayIconImagePicker.tsx +++ b/src/renderer/components/settings/TrayIconImagePicker.tsx @@ -6,7 +6,7 @@ import { Forms, Switch, Toasts } from "@vencord/types/webpack/common"; import { Settings } from "renderer/settings"; -import { STATIC_DIR } from "shared/paths"; + import { SettingsComponent } from "./Settings"; export const TrayIconImagePicker: SettingsComponent = ({ settings }) => { From 1ea46567bdc719c36d1635591ee865e4a58b51a2 Mon Sep 17 00:00:00 2001 From: MrGarlic Date: Wed, 5 Jun 2024 07:45:41 -0400 Subject: [PATCH 19/20] replace pencil icon with discord client pencil icon --- src/renderer/components/settings/TrayIconImagePicker.tsx | 7 ++++--- src/renderer/components/settings/settings.css | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/settings/TrayIconImagePicker.tsx b/src/renderer/components/settings/TrayIconImagePicker.tsx index a8cb52b..ad45824 100644 --- a/src/renderer/components/settings/TrayIconImagePicker.tsx +++ b/src/renderer/components/settings/TrayIconImagePicker.tsx @@ -4,11 +4,14 @@ * Copyright (c) 2023 Vendicated and Vencord contributors */ +import { findByPropsLazy } from "@vencord/types/webpack"; import { Forms, Switch, Toasts } from "@vencord/types/webpack/common"; import { Settings } from "renderer/settings"; import { SettingsComponent } from "./Settings"; +const { PencilIcon } = findByPropsLazy("PencilIcon"); + export const TrayIconImagePicker: SettingsComponent = ({ settings }) => { return ( <> @@ -44,10 +47,8 @@ export const TrayIconImagePicker: SettingsComponent = ({ settings }) => { width="48" height="48" > - { diff --git a/src/renderer/components/settings/settings.css b/src/renderer/components/settings/settings.css index 23f0191..8bf7a9a 100644 --- a/src/renderer/components/settings/settings.css +++ b/src/renderer/components/settings/settings.css @@ -51,7 +51,7 @@ display: block; opacity: 0; position: absolute; - top: 4px; + top: 3px; left: 4px; } From 663a2a576b346c54d49cea151a5b2d48a146860a Mon Sep 17 00:00:00 2001 From: MrGarlic1 Date: Mon, 17 Jun 2024 01:09:13 -0400 Subject: [PATCH 20/20] feat: store image in settings instead of using direct path --- src/main/constants.ts | 1 + src/main/ipc.ts | 10 ++++------ src/main/mainWindow.ts | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/constants.ts b/src/main/constants.ts index 1bce303..45a4749 100644 --- a/src/main/constants.ts +++ b/src/main/constants.ts @@ -18,6 +18,7 @@ export const PORTABLE = const LEGACY_DATA_DIR = join(app.getPath("appData"), "VencordDesktop", "VencordDesktop"); export const DATA_DIR = process.env.VENCORD_USER_DATA_DIR || (PORTABLE ? join(vesktopDir, "Data") : join(app.getPath("userData"))); +export const TRAY_ICON_PATH = join(DATA_DIR, "settings", "tray_icon"); mkdirSync(DATA_DIR, { recursive: true }); diff --git a/src/main/ipc.ts b/src/main/ipc.ts index ab0f778..1d2b1ce 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -8,7 +8,7 @@ if (process.platform === "linux") import("./venmic"); import { execFile } from "child_process"; import { app, BrowserWindow, clipboard, dialog, nativeImage, RelaunchOptions, session, shell } from "electron"; -import { mkdirSync, readFileSync, watch } from "fs"; +import { copyFileSync, mkdirSync, readFileSync, watch } from "fs"; import { open, readFile } from "fs/promises"; import { release } from "os"; import { join } from "path"; @@ -18,7 +18,7 @@ import { debounce } from "shared/utils/debounce"; import { IpcEvents } from "../shared/IpcEvents"; import { setBadgeCount } from "./appBadge"; import { autoStart } from "./autoStart"; -import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; +import { TRAY_ICON_PATH, VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; import { mainWin } from "./mainWindow"; import { Settings } from "./settings"; import { handle, handleSync } from "./utils/ipcWrappers"; @@ -44,10 +44,8 @@ handleSync( handleSync(IpcEvents.GET_TRAY_ICON, () => { if (!Settings.store.trayIconPath) return nativeImage.createFromPath(ICON_PATH).toDataURL(); - - const img = nativeImage.createFromPath(Settings.store.trayIconPath).resize({ width: 64, height: 64 }); + const img = nativeImage.createFromPath(TRAY_ICON_PATH).resize({ width: 64, height: 64 }); if (img.isEmpty()) return nativeImage.createFromPath(ICON_PATH).toDataURL(); - return img.toDataURL(); }); @@ -137,7 +135,7 @@ handle(IpcEvents.SELECT_TRAY_ICON, async () => { const dir = res.filePaths[0]; const image = nativeImage.createFromPath(dir); if (image.isEmpty()) return "invalid"; - + copyFileSync(dir, TRAY_ICON_PATH); return dir; }); diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 8d70d85..222f39f 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -35,6 +35,7 @@ import { MessageBoxChoice, MIN_HEIGHT, MIN_WIDTH, + TRAY_ICON_PATH, VENCORD_FILES_DIR } from "./constants"; import { Settings, State, VencordSettings } from "./settings"; @@ -124,7 +125,7 @@ function initTray(win: BrowserWindow) { } ]); var trayImage = nativeImage.createFromPath(ICON_PATH); - if (Settings.store.trayIconPath) trayImage = nativeImage.createFromPath(Settings.store.trayIconPath); + if (Settings.store.trayIconPath) trayImage = nativeImage.createFromPath(TRAY_ICON_PATH); if (trayImage.isEmpty()) trayImage = nativeImage.createFromPath(ICON_PATH); if (process.platform === "darwin") {