mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-26 02:03:49 +02:00
Fix launchcommands on Linux (#1352)
* feat: expose IPC listener to electron world * feat: add listener + rouing to old function + remove old functions * feat: register vrcx prefix + route launch arguments to electron
This commit is contained in:
@@ -14,8 +14,19 @@ const { spawn, spawnSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const https = require('https');
|
||||
|
||||
const VRCX_URI_PREFIX = "vrcx"
|
||||
|
||||
//app.disableHardwareAcceleration();
|
||||
|
||||
if (process.defaultApp) {
|
||||
if (process.argv.length >= 2) {
|
||||
app.setAsDefaultProtocolClient(VRCX_URI_PREFIX, process.execPath, [path.resolve(process.argv[1])])
|
||||
} else {
|
||||
app.setAsDefaultProtocolClient(VRCX_URI_PREFIX)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
// Include bundled .NET runtime
|
||||
const bundledDotNetPath = path.join(
|
||||
@@ -105,6 +116,7 @@ ipcMain.handle('callDotNetMethod', (event, className, methodName, args) => {
|
||||
return interopApi.callMethod(className, methodName, args);
|
||||
});
|
||||
|
||||
/** @type {BrowserWindow} */
|
||||
let mainWindow = undefined;
|
||||
|
||||
const VRCXStorage = interopApi.getDotNetObject('VRCXStorage');
|
||||
@@ -112,6 +124,26 @@ const hasAskedToMoveAppImage =
|
||||
VRCXStorage.Get('VRCX_HasAskedToMoveAppImage') === 'true';
|
||||
let isCloseToTray = VRCXStorage.Get('VRCX_CloseToTray') === 'true';
|
||||
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
const strip_vrcx_prefix_regex = new RegExp("^" + VRCX_URI_PREFIX + ":\/\/")
|
||||
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
if (mainWindow && commandLine.length >= 2) {
|
||||
mainWindow.webContents.send('launch-command', commandLine.pop().trim().replace(strip_vrcx_prefix_regex, ""))
|
||||
}
|
||||
})
|
||||
|
||||
app.on('open-url', (event, url) => {
|
||||
if (mainWindow && url) {
|
||||
mainWindow.webContents.send('launch-command', url.replace(strip_vrcx_prefix_regex, ""))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
ipcMain.handle('applyWindowSettings', (event, position, size, state) => {
|
||||
if (position) {
|
||||
mainWindow.setPosition(parseInt(position.x), parseInt(position.y));
|
||||
@@ -270,7 +302,7 @@ function createWindow() {
|
||||
icon: path.join(rootDir, 'VRCX.png'),
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
}
|
||||
});
|
||||
applyWindowState();
|
||||
|
||||
Reference in New Issue
Block a user