mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-27 17:00:52 +01:00
Initial notification icon support
As icon locations are platform dependent, iterate through paths & add to notifications
This commit is contained in:
parent
810d25b35c
commit
0681854794
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user