-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
executable file
·47 lines (35 loc) · 1.12 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
// load config from ~/.serenytics-menubar
require('dotenv').config({path: process.env.HOME + '/.serenytics-menubar'});
const menubar = require('menubar');
const {dialog} = require('electron');
process.on('uncaughtException', function (err) {
dialog.showErrorBox('Uncaught Exception: ' + err.message, err.stack || '')
app.app.quit()
});
const app = menubar({
width: 1350,
height: 900,
preloadWindow: true
});
app.on('ready', function ready () {
console.log('Serenytics menubar is ready!');
});
app.on('after-create-window', function () {
// mb.window.openDevTools();
const env = process.env;
const config = {
username: env.username,
password: env.password,
webAppUuid: env.webAppUuid
};
if (!config.username || !config.password) {
dialog.showErrorBox('Configuration error!', `
You need to create a file named ~/.serenytics-menubar containing:
username=YOUR_USERNAME
password=YOUR_PASSWORD
webAppUuid=OPTIONAL_YOUR_DASHBOARD_UUID
`);
app.app.quit()
}
app.window.webContents.executeJavaScript(`window.main('${JSON.stringify(config)}')`);
});