-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
53 lines (48 loc) · 1.34 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
46
47
48
49
50
51
52
53
const electron = require('electron')
const config = require('./config')
const app = electron.app;
const Tray = electron.Tray;
const BrowserWindow = electron.BrowserWindow;
//Prevents dock icon to display
if (process.platform == 'darwin') {
//app.dock.hide();
}
//Prevents multiples instances of the program
app.makeSingleInstance(function() {})
app.on('ready', function() {
//Sets the Tray icon
var appIcon = null;
appIcon = new Tray('./img/trayTemplate.png');
appIcon.setToolTip(config.appname);
//Main app Window
var mw_width = 300
var mw_height = 220
var MainWindow = new BrowserWindow({
width: mw_width,
height: mw_height,
show: false,
resizable: false,
alwaysOnTop: true,
skipTaskbar: true,
frame: false,
});
MainWindow.loadURL('file://' + __dirname + '/windows/main.html');
MainWindow.webContents.openDevTools();
//Hide the main window when blured
MainWindow.on('blur', function() {
this.hide();
})
//Open main window when tray icon is clicked
appIcon.on('click', function(event, bounds) {
var x = bounds.x + (bounds.width / 2) - (mw_width / 2);
if (bounds.y < 100) {
//tray at top
var y = bounds.y + bounds.height;
} else {
//tray at bottom
var y = bounds.y - bounds.height - mw_height;
}
MainWindow.setPosition(x, y);
MainWindow.show();
})
})