mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { registerEvent } from "../register-event";
|
|
import createDesktopShortcut from "create-desktop-shortcuts";
|
|
import path from "node:path";
|
|
import { app } from "electron";
|
|
import { removeSymbolsFromName } from "@shared";
|
|
import { GameShop } from "@types";
|
|
import { gamesSublevel, levelKeys } from "@main/level";
|
|
|
|
const createGameShortcut = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
shop: GameShop,
|
|
objectId: string
|
|
): Promise<boolean> => {
|
|
const gameKey = levelKeys.game(shop, objectId);
|
|
const game = await gamesSublevel.get(gameKey);
|
|
|
|
if (game) {
|
|
const filePath = game.executablePath;
|
|
|
|
const windowVbsPath = app.isPackaged
|
|
? path.join(process.resourcesPath, "windows.vbs")
|
|
: undefined;
|
|
|
|
const options = {
|
|
filePath,
|
|
name: removeSymbolsFromName(game.title),
|
|
outputPath: app.getPath("desktop"),
|
|
};
|
|
|
|
return createDesktopShortcut({
|
|
windows: { ...options, VBScriptPath: windowVbsPath },
|
|
linux: options,
|
|
osx: options,
|
|
});
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
registerEvent("createGameShortcut", createGameShortcut);
|