-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
45 lines (39 loc) · 1.04 KB
/
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
45
/* eslint-disable no-use-before-define */
const electron = require('electron');
const ChronoTray = require('./app/chronotray');
const ws = require('windows-shortcuts');
const {
app,
BrowserWindow,
ipcMain,
} = electron;
let mainwWindow;
let tray;
app.on('ready', () => {
mainwWindow = new BrowserWindow({
height: 160,
width: 350,
frame: false,
resizable: false,
show: false,
skipTaskbar: true,
});
tray = new ChronoTray(`${__dirname}/images/robot.png`, mainwWindow);
mainwWindow.loadURL(`file://${__dirname}/index.html`);
mainwWindow.on('blur', () => {
setTimeout(() => {
mainwWindow.hide();
}, 200);
});
if (process.env.NODE_ENV !== 'production' && process.platform === 'win32') {
ws.create('%APPDATA%/Microsoft/Windows/Start Menu/Programs/Electron.lnk', process.execPath);
app.setAppUserModelId(process.execPath);
}
});
ipcMain.on('timeUpdate', (event, timeUpdate) => {
if (process.platform === 'darwin') {
tray.setTitle(timeUpdate);
} else {
tray.setToolTip(timeUpdate);
}
});