-
Notifications
You must be signed in to change notification settings - Fork 48
/
tray.js
43 lines (38 loc) · 840 Bytes
/
tray.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
const electron = require('electron');
const path = require('path');
const app = electron.app;
let tray = null;
exports.create = function(mainWindow) {
if (process.platform === 'darwin' || tray) {
return;
}
const iconPath = path.join(__dirname, '/public/images/batcave_small.png');
const toggleWin = function(){
if (mainWindow.isVisible()) {
mainWindow.hide();
} else {
mainWindow.show();
}
};
const contextMenu = electron.Menu.buildFromTemplate([
{
label: 'Restore Batcave',
click() {
toggleWin();
}
},
{
type: 'separator'
},
{
label: 'Quit',
click() {
app.quit();
}
}
]);
tray = new electron.Tray(iconPath);
tray.setToolTip('Batcave');
tray.setContextMenu(contextMenu);
tray.on('click', toggleWin);
};