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 = `
[Desktop Entry]
Type=Application
Version=1.0
Version={{VERSION}}
Name={{APP_NAME}}
Comment={{APP_NAME}} startup script
Comment={{COMMENT}}
Exec={{APP_PATH}} {{ARGS}}
StartupNotify=false
Terminal=false
@ -38,10 +38,26 @@ export default class AutoLaunchAPILinux extends AutoLaunchAPI {
programArguments.push(extraArgs);
}
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()
.replace(/{{APP_NAME}}/g, this.appName)
.replace(/{{APP_PATH}}/g, this.appPath)
.replace(/{{COMMENT}}/g, comment)
.replace(/{{VERSION}}/g, version)
.replace(/{{ARGS}}/g, args);
return fileBasedUtilities.createFile({

View file

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

View file

@ -54,12 +54,6 @@ interface Stats {
const bz2 = require('unbzip2-stream');
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({
name: 'monerod-gui',
@ -67,16 +61,17 @@ let autoLauncher = new AutoLaunch({
options: {
extraArguments: [
'--auto-launch'
]
],
linux: {
comment: 'Monerod GUI startup script',
version: '0.1.1'
}
}
});
const isAutoLaunched: boolean = process.argv.includes('--auto-launch');
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 isHidden: boolean = false;
let isQuitting: boolean = false;
@ -174,9 +169,6 @@ function createWindow(): BrowserWindow {
win?.hide();
isHidden = true;
}
console.log("Clicked monero gui icon tray");
console.log(event);
});
win.on('close', (event) => {
@ -590,7 +582,18 @@ try {
// initialization and is ready to create browser windows.
// 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
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.
app.on('window-all-closed', () => {