Main process minor fixes

This commit is contained in:
everoddandeven 2024-10-29 15:42:58 +01:00
parent 1f9c79e6b4
commit a4e3ea5224
3 changed files with 39 additions and 16 deletions

View file

@ -8,9 +8,9 @@ const LINUX_AUTOSTART_DIR = '~/.config/autostart';
const LINUX_DESKTOP = ` const LINUX_DESKTOP = `
[Desktop Entry] [Desktop Entry]
Type=Application Type=Application
Version=1.0 Version={{VERSION}}
Name={{APP_NAME}} Name={{APP_NAME}}
Comment={{APP_NAME}} startup script Comment={{COMMENT}}
Exec={{APP_PATH}} {{ARGS}} Exec={{APP_PATH}} {{ARGS}}
StartupNotify=false StartupNotify=false
Terminal=false Terminal=false
@ -38,10 +38,26 @@ export default class AutoLaunchAPILinux extends AutoLaunchAPI {
programArguments.push(extraArgs); programArguments.push(extraArgs);
} }
const args = programArguments.join(' '); const args = programArguments.join(' ');
let comment = `${this.appName} startup script`;
let version = `1.0`;
if (this.options.linux) {
if (this.options.linux.comment && this.options.linux.comment != '')
{
comment = this.options.linux.comment;
}
if (this.options.linux.version && this.options.linux.version != '')
{
version = this.options.linux.version;
}
}
const desktop = LINUX_DESKTOP.trim() const desktop = LINUX_DESKTOP.trim()
.replace(/{{APP_NAME}}/g, this.appName) .replace(/{{APP_NAME}}/g, this.appName)
.replace(/{{APP_PATH}}/g, this.appPath) .replace(/{{APP_PATH}}/g, this.appPath)
.replace(/{{COMMENT}}/g, comment)
.replace(/{{VERSION}}/g, version)
.replace(/{{ARGS}}/g, args); .replace(/{{ARGS}}/g, args);
return fileBasedUtilities.createFile({ return fileBasedUtilities.createFile({

View file

@ -20,5 +20,9 @@ export interface AutoLaunchOptions {
mac?: { mac?: {
useLaunchAgent?: boolean; useLaunchAgent?: boolean;
}, },
linux?: {
version?: string;
comment?: string;
},
extraArguments?: string[]; extraArguments?: string[];
} }

View file

@ -54,12 +54,6 @@ interface Stats {
const bz2 = require('unbzip2-stream'); const bz2 = require('unbzip2-stream');
app.setName('Monero Daemon'); app.setName('Monero Daemon');
const gotInstanceLock = app.requestSingleInstanceLock();
if (!gotInstanceLock) {
dialog.showErrorBox('Error', 'Another instance of monerod GUI is running');
app.quit();
}
let autoLauncher = new AutoLaunch({ let autoLauncher = new AutoLaunch({
name: 'monerod-gui', name: 'monerod-gui',
@ -67,16 +61,17 @@ let autoLauncher = new AutoLaunch({
options: { options: {
extraArguments: [ extraArguments: [
'--auto-launch' '--auto-launch'
] ],
linux: {
comment: 'Monerod GUI startup script',
version: '0.1.1'
}
} }
}); });
const isAutoLaunched: boolean = process.argv.includes('--auto-launch'); const isAutoLaunched: boolean = process.argv.includes('--auto-launch');
const minimized: boolean = process.argv.includes('--hidden'); const minimized: boolean = process.argv.includes('--hidden');
dialog.showErrorBox(`Info`, `is auto launched: ${isAutoLaunched}, process.argv: ${process.argv.join(' ')}`)
let win: BrowserWindow | null = null; let win: BrowserWindow | null = null;
let isHidden: boolean = false; let isHidden: boolean = false;
let isQuitting: boolean = false; let isQuitting: boolean = false;
@ -174,9 +169,6 @@ function createWindow(): BrowserWindow {
win?.hide(); win?.hide();
isHidden = true; isHidden = true;
} }
console.log("Clicked monero gui icon tray");
console.log(event);
}); });
win.on('close', (event) => { win.on('close', (event) => {
@ -590,7 +582,18 @@ try {
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
// Added 400 ms to fix the black background issue while using transparent window. More detais at https://github.com/electron/electron/issues/15947 // Added 400 ms to fix the black background issue while using transparent window. More detais at https://github.com/electron/electron/issues/15947
app.on('ready', () => setTimeout(createWindow, 400)); app.on('ready', () => {
Menu.setApplicationMenu(null);
const gotInstanceLock = app.requestSingleInstanceLock();
if (!gotInstanceLock) {
dialog.showErrorBox('', 'Another instance of monerod GUI is running');
app.quit();
return;
}
setTimeout(createWindow, 400);
});
// Quit when all windows are closed. // Quit when all windows are closed.
app.on('window-all-closed', () => { app.on('window-all-closed', () => {