mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 05:24:55 +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
|
||||
? path.join(process.resourcesPath, "seeds")
|
||||
: path.join(__dirname, "..", "..", "seeds");
|
||||
|
||||
export const windowsStartupPath = path.join(
|
||||
app.getPath("appData"),
|
||||
"Microsoft",
|
||||
"Windows",
|
||||
"Start Menu",
|
||||
"Programs",
|
||||
"Startup"
|
||||
);
|
||||
|
@ -1,18 +1,35 @@
|
||||
import { windowsStartupPath } from "@main/constants";
|
||||
import { registerEvent } from "../register-event";
|
||||
import AutoLaunch from "auto-launch";
|
||||
import { app } from "electron";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const autoLaunch = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
enabled: boolean
|
||||
) => {
|
||||
const appLauncher = new AutoLaunch({
|
||||
name: app.getName(),
|
||||
});
|
||||
if (enabled) {
|
||||
appLauncher.enable().catch();
|
||||
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 {
|
||||
appLauncher.disable().catch();
|
||||
const appLauncher = new AutoLaunch({
|
||||
name: app.getName(),
|
||||
});
|
||||
if (enabled) {
|
||||
appLauncher.enable().catch();
|
||||
} else {
|
||||
appLauncher.disable().catch();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user