This repository has been archived by the owner on Feb 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.js
74 lines (64 loc) · 1.75 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var os = require('os');
var fs = require("fs");
var app = require('app');
var Menu = require('menu');
var Tray = require('tray');
var path = require('path');
var globalShortcut = require('global-shortcut');
require('electron-debug')();
require('crash-reporter').start();
voiceBox = require('./app/voicebox');
// load the responders manager
respondersManager = require('./app/responders_manager');
var settings = require('./app/settings');
var updater = require('./app/updater');
updater.checkForUpdate(app);
// Hide the dock icon
if(os.platform() === 'darwin')
app.dock.hide();
// setting some chromium flags to enable window transparency on linux
if(os.platform() === 'linux'){
app.commandLine.appendSwitch('enable-transparent-visuals');
app.commandLine.appendSwitch('disable-gpu');
}
trayIcon = null;
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
// Tray icon
trayIcon = new Tray(settings.iconPath());
var contextMenu = Menu.buildFromTemplate([
{
label: 'Responders Manager',
click: function(){
respondersManager.open();
}
},
{
label: 'Settings',
click: function(){
settings.open();
}
},
{
label: 'Quit',
click: function(){
app.quit()
}
}
]);
trayIcon.setContextMenu(contextMenu);
// Register the shortcut
globalShortcut.register('alt+s', function() {
if ( voiceBox.listening ){
voiceBox.waiting_for_response = false
voiceBox.stopListening()
}else{
voiceBox.listen()
}
})
});
// Quit when all windows are closed.
app.on('window-all-closed', function() {
// empty event to prevent app quiting when all windows are closed
});