move electron folder

This commit is contained in:
Anton Bracke
2022-02-22 10:41:55 +01:00
parent ac18aab773
commit 41be011d5e
36 changed files with 19 additions and 18 deletions
+41
View File
@@ -0,0 +1,41 @@
import AutoLaunch from "auto-launch";
import { app } from "electron";
import electronIsDev from "electron-is-dev";
import settings from "./settings";
export async function updateAutoLaunch() {
let isAutoLaunchEnabled = settings.get("auto_launch_enabled");
// set default to enabled
if (isAutoLaunchEnabled === undefined) {
settings.set("auto_launch_enabled", true);
isAutoLaunchEnabled = true;
}
// Don't run this in development
if (electronIsDev) {
return;
}
// `setLoginItemSettings` doesn't support linux
if (process.platform === "linux") {
const autoLauncher = new AutoLaunch({
name: "WorkAdventure",
isHidden: true,
});
if (isAutoLaunchEnabled) {
await autoLauncher.enable();
} else {
await autoLauncher.disable();
}
return;
}
app.setLoginItemSettings({
openAtLogin: isAutoLaunchEnabled,
openAsHidden: true,
});
}