Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 6 additions & 43 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {app, BrowserWindow, Tray, Notification, Menu, globalShortcut, powerSaveBlocker } = require('electron/main');
const {app, BrowserWindow, globalShortcut, powerSaveBlocker } = require('electron/main');
const path = require('node:path');
const {ipcMain} = require('electron')
const http = require('http');
Expand All @@ -8,7 +8,6 @@ const net = require('net');
const gotTheLock = app.requestSingleInstanceLock();

let powerSaveBlockerId;
let tray;
let s_mainWindow;
let msgbacklog=[];
let httpServer;
Expand Down Expand Up @@ -185,9 +184,6 @@ app.on('before-quit', () => {
if (httpServer) {
httpServer.close();
}
if (tray) {
tray.destroy();
}
});

process.on('SIGINT', () => {
Expand Down Expand Up @@ -217,45 +213,12 @@ if (!gotTheLock) {
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
});
s_mainWindow.webContents.once('dom-ready', function() {
if (msgbacklog.length>0) {
s_mainWindow.webContents.send('updateMsg',msgbacklog.pop());
}
});

// Create the tray icon
const path = require('path');
const iconPath = path.join(__dirname, 'icon1616.png');
tray = new Tray(iconPath);

const contextMenu = Menu.buildFromTemplate([
{ label: 'Show App', click: () => s_mainWindow.show() },
{ label: 'Quit', click: () => {
console.log("Exiting");
app.isQuitting = true;
app.quit();
}
},
]);

tray.setContextMenu(contextMenu);
tray.setToolTip(require('./package.json').name + " V" + require('./package.json').version);

s_mainWindow.on('minimize', (event) => {
event.preventDefault();
s_mainWindow.hide(); // Hides the window instead of minimizing it to the taskbar
});

s_mainWindow.on('close', (event) => {
if (!app.isQuitting) {
event.preventDefault();
s_mainWindow.hide();
}
s_mainWindow.webContents.once('dom-ready', function() {
if (msgbacklog.length>0) {
s_mainWindow.webContents.send('updateMsg',msgbacklog.pop());
}
});
});
if (app.isPackaged && (process.platform === 'darwin')) {
app.dock.hide();
}
})
}

app.on('window-all-closed', function () {
Expand Down