@@ -255,6 +255,35 @@ app.on("ready", () => {
255
255
} , 20000 ) ;
256
256
}
257
257
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
+
258
287
mainWindow = createMainWindow ( ) ;
259
288
setApplicationMenu ( mainWindow ) ;
260
289
if ( config . get ( "options.restartOnConfigChanges" ) ) {
0 commit comments