feat: implement automatic shortcut creation upon automatic path binding

This commit is contained in:
Moyasee
2026-01-28 13:38:49 +02:00
parent 53bd31dec0
commit 2e2a95c314

View File

@@ -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<void> {
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[]