From 0681854794495a8576e29bf7c00a661f06ded473 Mon Sep 17 00:00:00 2001 From: MrPenguin07 <127086564+MrPenguin07@users.noreply.github.com> Date: Mon, 12 Feb 2024 12:38:31 +0000 Subject: [PATCH 1/2] Initial notification icon support As icon locations are platform dependent, iterate through paths & add to notifications --- electron/utils/show-notification.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/electron/utils/show-notification.ts b/electron/utils/show-notification.ts index 0723888..b5acbf6 100644 --- a/electron/utils/show-notification.ts +++ b/electron/utils/show-notification.ts @@ -1,11 +1,31 @@ import { Notification } from "electron/main"; import { turnOffNotifications } from "./config-variables"; +import * as fs from 'fs'; export default function showNotification(title: string, body: string) { if (turnOffNotifications) return; - new Notification({ + + const iconPaths = [ + "/app/share/icons/hicolor/128x128/apps/org.upscayl.Upscayl.png", // flatpak icon + "__appImage-x64/usr/share/icons/hicolor/128x128/apps/upscayl.png", // appimage icon + "/usr/share/icons/hicolor/128x128/apps/upscayl.png", // deb & rpm icon + "resources/128x128.png", // win icon + "build/icon.icns", // mac icon + ]; + + // Find the first available icon path + let iconPath = ''; + for (const path of iconPaths) { + if (fs.existsSync(path)) { + iconPath = path; + break; + } + } + + const notification = new Notification({ title, body, closeButtonText: "Close", + icon: iconPath, }).show(); } From a455569a4838e5df1337b0c997fa0b9236085b15 Mon Sep 17 00:00:00 2001 From: NayamAmarshe Date: Wed, 15 May 2024 15:49:26 +0530 Subject: [PATCH 2/2] Update electron/utils/show-notification.ts --- electron/utils/show-notification.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/utils/show-notification.ts b/electron/utils/show-notification.ts index b5acbf6..18e2e07 100644 --- a/electron/utils/show-notification.ts +++ b/electron/utils/show-notification.ts @@ -1,6 +1,6 @@ import { Notification } from "electron/main"; import { turnOffNotifications } from "./config-variables"; -import * as fs from 'fs'; +import fs from 'fs'; export default function showNotification(title: string, body: string) { if (turnOffNotifications) return;