mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-29 13:51:02 +00:00
feat: implement automatic shortcut creation upon automatic path binding
This commit is contained in:
@@ -8,6 +8,10 @@ import { WindowManager } from "./window-manager";
|
|||||||
import { publishExtractionCompleteNotification } from "./notifications";
|
import { publishExtractionCompleteNotification } from "./notifications";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
import { GameExecutables } from "./game-executables";
|
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;
|
const PROGRESS_THROTTLE_MS = 1000;
|
||||||
|
|
||||||
@@ -204,6 +208,8 @@ export class GameFilesManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
WindowManager.mainWindow?.webContents.send("on-library-batch-complete");
|
WindowManager.mainWindow?.webContents.send("on-library-batch-complete");
|
||||||
|
|
||||||
|
await this.createDesktopShortcutForGame(game.title, foundExePath);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(
|
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(
|
private async findExecutableInFolder(
|
||||||
folderPath: string,
|
folderPath: string,
|
||||||
executableNames: string[]
|
executableNames: string[]
|
||||||
|
|||||||
Reference in New Issue
Block a user