diff --git a/src/main/services/game-files-manager.ts b/src/main/services/game-files-manager.ts index 722e1c9e..307903aa 100644 --- a/src/main/services/game-files-manager.ts +++ b/src/main/services/game-files-manager.ts @@ -8,6 +8,10 @@ import { WindowManager } from "./window-manager"; import { publishExtractionCompleteNotification } from "./notifications"; import { logger } from "./logger"; import { GameExecutables } from "./game-executables"; +import createDesktopShortcut from "create-desktop-shortcuts"; +import { app } from "electron"; +import { removeSymbolsFromName } from "@shared"; +import { SystemPath } from "./system-path"; const PROGRESS_THROTTLE_MS = 1000; @@ -204,6 +208,8 @@ export class GameFilesManager { }); WindowManager.mainWindow?.webContents.send("on-library-batch-complete"); + + await this.createDesktopShortcutForGame(game.title, foundExePath); } } catch (err) { logger.error( @@ -213,6 +219,40 @@ export class GameFilesManager { } } + private async createDesktopShortcutForGame( + gameTitle: string, + executablePath: string + ): Promise { + try { + const windowVbsPath = app.isPackaged + ? path.join(process.resourcesPath, "windows.vbs") + : undefined; + + const options = { + filePath: executablePath, + name: removeSymbolsFromName(gameTitle), + outputPath: SystemPath.getPath("desktop"), + }; + + const success = createDesktopShortcut({ + windows: { ...options, VBScriptPath: windowVbsPath }, + linux: options, + osx: options, + }); + + if (success) { + logger.info( + `[GameFilesManager] Created desktop shortcut for ${this.objectId}` + ); + } + } catch (err) { + logger.error( + `[GameFilesManager] Error creating desktop shortcut: ${this.objectId}`, + err + ); + } + } + private async findExecutableInFolder( folderPath: string, executableNames: string[]