Skip to content

Commit

Permalink
AutoStart settings (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
noisekit authored Jun 13, 2023
1 parent 97380d6 commit 4473b73
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function updateContextMenu() {
tray.setContextMenu(
Menu.buildFromTemplate([
menu.app,
menu.autoStart,
menu.devTools,
menu.dock,
{ type: 'separator' },
Expand All @@ -85,6 +86,7 @@ function updateContextMenu() {
app.dock.setMenu(
Menu.buildFromTemplate([
menu.app,
menu.autoStart,
menu.devTools,
menu.tray,
{ type: 'separator' },
Expand Down Expand Up @@ -156,6 +158,18 @@ function generateMenuItems() {
} else {
mainWindow.show();
}
updateContextMenu();
},
},
autoStart: {
label: app.getLoginItemSettings().openAtLogin
? 'Disable AutoStart'
: 'Enable AutoStart',
click: () => {
const settings = app.getLoginItemSettings();
settings.openAtLogin = !settings.openAtLogin;
app.setLoginItemSettings(settings);
updateContextMenu();
},
},
devTools: {
Expand All @@ -171,6 +185,7 @@ function generateMenuItems() {
mainWindow.webContents.openDevTools({ mode: 'detach' });
}
}
updateContextMenu();
},
},
dock: {
Expand All @@ -185,6 +200,7 @@ function generateMenuItems() {
app.dock.show();
}
}
updateContextMenu();
},
},
tray: {
Expand All @@ -193,12 +209,11 @@ function generateMenuItems() {
if (tray && !tray.isDestroyed()) {
await settings.set('tray', false);
tray.destroy();
updateContextMenu();
} else {
await settings.set('tray', true);
createTray();
updateContextMenu();
}
updateContextMenu();
},
},
separator: {
Expand Down

0 comments on commit 4473b73

Please sign in to comment.