Skip to content

Commit 4473b73

Browse files
authored
AutoStart settings (#20)
1 parent 97380d6 commit 4473b73

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/main/main.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function updateContextMenu() {
7373
tray.setContextMenu(
7474
Menu.buildFromTemplate([
7575
menu.app,
76+
menu.autoStart,
7677
menu.devTools,
7778
menu.dock,
7879
{ type: 'separator' },
@@ -85,6 +86,7 @@ function updateContextMenu() {
8586
app.dock.setMenu(
8687
Menu.buildFromTemplate([
8788
menu.app,
89+
menu.autoStart,
8890
menu.devTools,
8991
menu.tray,
9092
{ type: 'separator' },
@@ -156,6 +158,18 @@ function generateMenuItems() {
156158
} else {
157159
mainWindow.show();
158160
}
161+
updateContextMenu();
162+
},
163+
},
164+
autoStart: {
165+
label: app.getLoginItemSettings().openAtLogin
166+
? 'Disable AutoStart'
167+
: 'Enable AutoStart',
168+
click: () => {
169+
const settings = app.getLoginItemSettings();
170+
settings.openAtLogin = !settings.openAtLogin;
171+
app.setLoginItemSettings(settings);
172+
updateContextMenu();
159173
},
160174
},
161175
devTools: {
@@ -171,6 +185,7 @@ function generateMenuItems() {
171185
mainWindow.webContents.openDevTools({ mode: 'detach' });
172186
}
173187
}
188+
updateContextMenu();
174189
},
175190
},
176191
dock: {
@@ -185,6 +200,7 @@ function generateMenuItems() {
185200
app.dock.show();
186201
}
187202
}
203+
updateContextMenu();
188204
},
189205
},
190206
tray: {
@@ -193,12 +209,11 @@ function generateMenuItems() {
193209
if (tray && !tray.isDestroyed()) {
194210
await settings.set('tray', false);
195211
tray.destroy();
196-
updateContextMenu();
197212
} else {
198213
await settings.set('tray', true);
199214
createTray();
200-
updateContextMenu();
201215
}
216+
updateContextMenu();
202217
},
203218
},
204219
separator: {

0 commit comments

Comments
 (0)