-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
44 lines (38 loc) · 1020 Bytes
/
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
var menubar = require('menubar')
var ipc = require('electron').ipcMain
var globalShortcut = require('global-shortcut')
var mb = menubar({
transparent: true,
width: 100,
hasShadow: false,
height: 100,
tooltip: 'Who\'s awesome?!'
})
mb.on('ready', function () {
var size = require('electron').screen.getPrimaryDisplay().workAreaSize
mb.setOption('width', size.width)
mb.setOption('height', size.height)
// Register a shortcut listener.
try {
globalShortcut.register('Command+Shift+1', function () {
mb.showWindow()
})
} catch (err) {
console.log(err)
}
})
mb.on('show', function () {
mb.window.webContents.send('start-countdown')
})
mb.on('after-create-window', function () {
mb.window.webContents.on('did-finish-load', function () {
mb.window.webContents.send('start-countdown')
})
})
mb.on('hide', function () {
mb.window.webContents.send('stop-countdown')
})
// when receive the abort message, close the app
ipc.on('abort', function () {
mb.hideWindow()
})