mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 13:34:54 +03:00
fix: add script to auto launch hydra on startup
This commit is contained in:
parent
82f72071f9
commit
9c99e56b70
3
resources/hydra.vbs
Normal file
3
resources/hydra.vbs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Set WshShell = CreateObject("WScript.Shell" )
|
||||||
|
WshShell.Run """%localappdata%\Programs\Hydra\Hydra.exe""", 0 'Must quote command if it has spaces; must escape quotes
|
||||||
|
Set WshShell = Nothing
|
@ -14,3 +14,12 @@ export const logsPath = path.join(app.getPath("appData"), "hydra", "logs");
|
|||||||
export const seedsPath = app.isPackaged
|
export const seedsPath = app.isPackaged
|
||||||
? path.join(process.resourcesPath, "seeds")
|
? path.join(process.resourcesPath, "seeds")
|
||||||
: path.join(__dirname, "..", "..", "seeds");
|
: path.join(__dirname, "..", "..", "seeds");
|
||||||
|
|
||||||
|
export const windowsStartupPath = path.join(
|
||||||
|
app.getPath("appData"),
|
||||||
|
"Microsoft",
|
||||||
|
"Windows",
|
||||||
|
"Start Menu",
|
||||||
|
"Programs",
|
||||||
|
"Startup"
|
||||||
|
);
|
||||||
|
@ -1,11 +1,27 @@
|
|||||||
|
import { windowsStartupPath } from "@main/constants";
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import AutoLaunch from "auto-launch";
|
import AutoLaunch from "auto-launch";
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
const autoLaunch = async (
|
const autoLaunch = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
) => {
|
) => {
|
||||||
|
if (!app.isPackaged) return;
|
||||||
|
|
||||||
|
if (process.platform == "win32") {
|
||||||
|
const destination = path.join(windowsStartupPath, "hydra.vbs");
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
const scriptPath = path.join(process.resourcesPath, "hydra.vbs");
|
||||||
|
|
||||||
|
fs.copyFileSync(scriptPath, destination);
|
||||||
|
} else {
|
||||||
|
fs.rmSync(destination);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
const appLauncher = new AutoLaunch({
|
const appLauncher = new AutoLaunch({
|
||||||
name: app.getName(),
|
name: app.getName(),
|
||||||
});
|
});
|
||||||
@ -14,6 +30,7 @@ const autoLaunch = async (
|
|||||||
} else {
|
} else {
|
||||||
appLauncher.disable().catch();
|
appLauncher.disable().catch();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("autoLaunch", autoLaunch);
|
registerEvent("autoLaunch", autoLaunch);
|
||||||
|
Loading…
Reference in New Issue
Block a user