-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (24 loc) · 931 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
const electron = require("electron");
const TimerTray = require("./app/timer_tray");
const MainWindow = require("./app/main_window");
const path = require("path");
const { app, ipcMain } = electron;
//its important to assign the class into variable.
//else the TimerTray class will be deleted by the garbage collector
let mainWindow;
let tray;
app.on("ready", () => {
//hide the dock by default
app.dock.hide();
//initialize the browser
mainWindow = new MainWindow(`file://${__dirname}/src/index.html`);
//initialize the tray icon and the tray object it self
const iconName =
process.platform == "win32" ? "windows-icon.png" : "iconTemplate.png";
const iconPath = path.join(__dirname, `./src/assets/${iconName}`);
tray = new TimerTray(iconPath, mainWindow);
});
//display time left at the tray, data come from the react app
ipcMain.on("update-timer", (event, timeLeft) => {
tray.setTitle(timeLeft);
});