-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
47 lines (42 loc) · 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import menubar from 'menubar';
import AutoLaunch from 'auto-launch';
import { Menu } from 'electron';
import dotenv from 'dotenv';
dotenv.config();
export const mb = menubar({
dir: __dirname + '/../',
preloadWindow: true,
height: 400,
width: 350,
});
let appLauncher = new AutoLaunch({ name: process.env.APP_SLUG });
const contextMenu = Menu.buildFromTemplate([
{
label: 'Launch on Login',
type: 'checkbox',
checked: false,
click: item => {
appLauncher.isEnabled().then(enabled => {
if (enabled) {
return appLauncher.disable().then(() => {
item.checked = false;
});
} else {
return appLauncher.enable().then(() => {
item.checked = true;
});
}
});
},
},
{
label: `Quit ${process.env.APP_NAME}`,
click: () => mb.app.quit(),
},
]);
mb.on('ready', () => {
console.log(`${process.env.APP_NAME} is Ready!!`);
mb.tray.on('right-click', () => {
mb.tray.popUpContextMenu(contextMenu);
});
});