From 3412b3504fdaafcd78be8ac00990b401933b64b3 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Sat, 7 Jan 2023 04:36:24 +0200 Subject: [PATCH] use snoretoast CLSID --- index.js | 14 +++++++++++--- plugins/notifications/interactive.js | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 7cf0a99e..7e4e5980 100644 --- a/index.js +++ b/index.js @@ -363,6 +363,9 @@ app.on("ready", () => { // Register appID on windows if (is.windows()) { + // Depends on SnoreToast version https://github.com/KDE/snoretoast/blob/master/CMakeLists.txt#L5 + const toastActivatorClsid = "eb1fdd5b-8f70-4b5a-b230-998a2dc19303"; + const appID = "com.github.th-ch.youtube-music"; app.setAppUserModelId(appID); const appLocation = process.execPath; @@ -372,7 +375,11 @@ app.on("ready", () => { const shortcutPath = path.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "YouTube Music.lnk"); try { // check if shortcut is registered and valid const shortcutDetails = electron.shell.readShortcutLink(shortcutPath); // throw error if doesn't exist yet - if (shortcutDetails.target !== appLocation || shortcutDetails.appUserModelId !== appID) { + if ( + shortcutDetails.target !== appLocation || + shortcutDetails.appUserModelId !== appID || + shortcutDetails.toastActivatorClsid !== toastActivatorClsid + ) { throw "needUpdate"; } } catch (error) { // if not valid -> Register shortcut @@ -381,9 +388,10 @@ app.on("ready", () => { error === "needUpdate" ? "update" : "create", { target: appLocation, - cwd: appLocation.slice(0, appLocation.lastIndexOf(path.sep)), + cwd: path.dirname(appLocation), description: "YouTube Music Desktop App - including custom plugins", - appUserModelId: appID + appUserModelId: appID, + toastActivatorClsid } ); } diff --git a/plugins/notifications/interactive.js b/plugins/notifications/interactive.js index e692d0c7..b7535ea0 100644 --- a/plugins/notifications/interactive.js +++ b/plugins/notifications/interactive.js @@ -51,7 +51,7 @@ function sendToaster(songInfo) { //download image and get path let imgSrc = notificationImage(songInfo, true); toDelete = { - appID: is.dev() ? undefined : "com.github.th-ch.youtube-music", + appID: "com.github.th-ch.youtube-music", title: songInfo.title || "Playing", message: songInfo.artist, id: parseInt(Math.random() * 1000000, 10),