mirror of
https://github.com/kopia/kopia.git
synced 2026-05-18 19:54:37 -04:00
* chore(ci): enforce consistent formatting of KopiaUI code * fix htmlui_changelog.sh * fix
51 lines
1.0 KiB
JavaScript
51 lines
1.0 KiB
JavaScript
import { ipcMain } from "electron";
|
|
import log from "electron-log";
|
|
|
|
import AutoLaunch from "auto-launch";
|
|
|
|
const autoLauncher = new AutoLaunch({
|
|
name: "Kopia",
|
|
mac: {
|
|
useLaunchAgent: true,
|
|
},
|
|
});
|
|
|
|
let enabled = false;
|
|
|
|
export function willLaunchAtStartup() {
|
|
return enabled;
|
|
}
|
|
|
|
export function toggleLaunchAtStartup() {
|
|
if (enabled) {
|
|
log.info("disabling autorun");
|
|
autoLauncher
|
|
.disable()
|
|
.then(() => {
|
|
enabled = false;
|
|
ipcMain.emit("launch-at-startup-updated");
|
|
})
|
|
.catch((err) => log.info(err));
|
|
} else {
|
|
log.info("enabling autorun");
|
|
autoLauncher
|
|
.enable()
|
|
.then(() => {
|
|
enabled = true;
|
|
ipcMain.emit("launch-at-startup-updated");
|
|
})
|
|
.catch((err) => log.info(err));
|
|
}
|
|
}
|
|
export function refreshWillLaunchAtStartup() {
|
|
autoLauncher
|
|
.isEnabled()
|
|
.then((isEnabled) => {
|
|
enabled = isEnabled;
|
|
ipcMain.emit("launch-at-startup-updated");
|
|
})
|
|
.catch(function (err) {
|
|
log.info("unable to get autoLauncher state", err);
|
|
});
|
|
}
|