forked from akashnimare/foco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·73 lines (65 loc) · 1.66 KB
/
index.js
File metadata and controls
executable file
·73 lines (65 loc) · 1.66 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const path = require('path')
const menubar = require('menubar')
const {Menu} = require('electron')
const APP_ICON = path.join(__dirname, '/build', 'icon')
const iconPath = () => {
if (process.platform === 'linux') {
return APP_ICON + 'linux.png'
}
if (process.platform === 'darwin') {
return APP_ICON + '.png'
}
if (process.platform === 'win32') {
return APP_ICON + '.ico'
}
}
const mb = menubar({transparent: true,
width: 320,
height: 580,
icon: iconPath()
})
const template = [{label: 'Foco',
submenu: [{label: 'Reload',
accelerator: 'CmdOrCtrl+R',
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.reload()
}
}
},
{
label: 'Quit App',
accelerator: 'CmdOrCtrl+Q',
role: 'quit'
},
{
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
click: () => {
mb.window.toggleDevTools()
}
}
]
}
]
mb.on('ready', () => {
console.log('Foco is ready to boost your productivity')
// setting this manually otherwise it will go in left
if (process.platform === 'linux') {
mb.setOption('x', 946)
mb.setOption('y', 10)
}
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
})
//right click menu for Tray
mb.on('after-create-window', function() {
const contextMenu = Menu.buildFromTemplate ([
{label: 'restart app', click: () => { mb.app.quit();mb.app.relaunch(); }},
{type: 'separator'},
{label: 'Quit', click: () => {mb.app.quit ();}}
])
mb.tray.on ('right-click', () => {
mb.tray.popUpContextMenu (contextMenu);
})
});