Files
stoat-desktop/src/native/autoLaunch.ts
T
Mihai 127d1430a9 fix: App Autostart (#68)
Signed-off-by: Mihai <cristian@mihaimuresan.com>
Co-authored-by: Mihai <cristian@mihaimuresan.com>
2026-02-13 00:25:05 -05:00

28 lines
655 B
TypeScript

import AutoLaunch from "auto-launch";
import { ipcMain } from "electron";
import { mainWindow } from "./window";
export const autoLaunch = new AutoLaunch({
name: "Stoat",
});
ipcMain.handle("getAutostart", async () => {
const enabled = await autoLaunch.isEnabled();
return enabled;
});
ipcMain.handle("setAutostart", async (_event, state: boolean) => {
if (state) {
await autoLaunch.enable();
console.log("Received new configuration autoStart: true");
} else {
await autoLaunch.disable();
console.log("Received new configuration autoStart: false");
}
const enabled = await autoLaunch.isEnabled();
return enabled;
});