Skip to content

Commit 5bc8e86

Browse files
authored
Merge pull request #270 from Araxeus/fix-normal-notification-showing-appID
fix notification showing appID instead of app name on windows
2 parents 5b00465 + cb6a5a4 commit 5bc8e86

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

index.js

+29
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,35 @@ app.on("ready", () => {
255255
}, 20000);
256256
}
257257

258+
// Register appID on windows
259+
if (is.windows()) {
260+
const appID = "com.github.th-ch.youtube-music";
261+
app.setAppUserModelId(appID);
262+
const appLocation = process.execPath;
263+
const appData = app.getPath("appData");
264+
// check shortcut validity if not in dev mode / running portable app
265+
if (!is.dev() && !appLocation.startsWith(path.join(appData, "..", "Local", "Temp"))) {
266+
const shortcutPath = path.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "YouTube Music.lnk");
267+
try { // check if shortcut is registered and valid
268+
const shortcutDetails = electron.shell.readShortcutLink(shortcutPath); // throw error if doesn't exist yet
269+
if (shortcutDetails.target !== appLocation || shortcutDetails.appUserModelId !== appID) {
270+
throw "needUpdate";
271+
}
272+
} catch (error) { // if not valid -> Register shortcut
273+
electron.shell.writeShortcutLink(
274+
shortcutPath,
275+
error === "needUpdate" ? "update" : "create",
276+
{
277+
target: appLocation,
278+
cwd: appLocation.slice(0, appLocation.lastIndexOf(path.sep)),
279+
description: "YouTube Music Desktop App - including custom plugins",
280+
appUserModelId: appID
281+
}
282+
);
283+
}
284+
}
285+
}
286+
258287
mainWindow = createMainWindow();
259288
setApplicationMenu(mainWindow);
260289
if (config.get("options.restartOnConfigChanges")) {

0 commit comments

Comments
 (0)