mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-26 20:31:03 +00:00
fix: add script to auto launch hydra on startup
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user