-
Notifications
You must be signed in to change notification settings - Fork 29
/
index.js
51 lines (47 loc) · 1.29 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
48
49
50
51
import menubar from 'menubar';
import AutoLaunch from 'auto-launch';
import { Menu } from 'electron';
export const mb = menubar({
dir: __dirname,
preloadWindow: true,
height: 330,
width: 440,
alwaysOnTop: false,
icon: __dirname + '/../assets/gif-icon.png'
});
let appLauncher = new AutoLaunch({ name: 'GifBar', isHidden: true });
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 GifBar`,
click: () => mb.app.quit(),
},
{
label: 'Toggle DevTools',
accelerator: 'Alt+CommandOrControl+I',
click: function () { mb.window.toggleDevTools() }
}
]);
mb.on('ready', () => {
console.log(`GifBar is Ready!!`);
mb.tray.on('right-click', () => {
mb.tray.popUpContextMenu(contextMenu);
});
});