use snoretoast CLSID

This commit is contained in:
Araxeus
2023-01-07 04:36:24 +02:00
parent fcb92fda84
commit 3412b3504f
2 changed files with 12 additions and 4 deletions

View File

@ -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
}
);
}