Use Wayland when available (#1089)

* Use Wayland when available

* X11 fallback option
This commit is contained in:
rs189
2025-01-24 18:29:54 +02:00
committed by GitHub
parent 8cf77af05c
commit 74bae43449
+34 -1
View File
@@ -9,6 +9,7 @@ const {
dialog, dialog,
Notification Notification
} = require('electron'); } = require('electron');
const { spawn } = require('child_process');
const fs = require('fs'); const fs = require('fs');
const https = require('https'); const https = require('https');
@@ -22,6 +23,7 @@ console.log('DOTNET_ROOT:', process.env.DOTNET_ROOT);
// get launch arguments // get launch arguments
const args = process.argv.slice(1); const args = process.argv.slice(1);
const noInstall = args.some((val) => val === '--no-install'); const noInstall = args.some((val) => val === '--no-install');
const x11 = args.some((val) => val === '--x11');
const homePath = getHomePath(); const homePath = getHomePath();
tryCopyFromWinePrefix(); tryCopyFromWinePrefix();
@@ -116,7 +118,38 @@ ipcMain.handle('app:restart', () => {
} }
}); });
function relaunchWithArgs(args) {
if (process.argv.includes('--ozone-platform-hint=auto')) {
console.log('Already running with correct arguments');
return;
}
const fullArgs = ['--ozone-platform-hint=auto', ...args];
let execPath = process.execPath;
if (appImagePath) {
execPath = appImagePath;
fullArgs.unshift('--appimage-extract-and-run');
}
console.log('Relaunching with args:', fullArgs);
const child = spawn(execPath, fullArgs, {
detached: true,
stdio: 'inherit'
});
child.unref();
app.exit(0);
}
function createWindow() { function createWindow() {
if (process.platform === 'linux' && !process.argv.includes('--ozone-platform-hint=auto') && !x11) {
relaunchWithArgs(process.argv.slice(1));
}
app.commandLine.appendSwitch('enable-speech-dispatcher'); app.commandLine.appendSwitch('enable-speech-dispatcher');
const x = parseInt(VRCXStorage.Get('VRCX_LocationX')) || 0; const x = parseInt(VRCXStorage.Get('VRCX_LocationX')) || 0;
@@ -372,7 +405,7 @@ async function installVRCX() {
const desktopFile = `[Desktop Entry] const desktopFile = `[Desktop Entry]
Name=VRCX Name=VRCX
Comment=Friendship management tool for VRChat Comment=Friendship management tool for VRChat
Exec=${appImagePath} Exec=${appImagePath} --ozone-platform-hint=auto
Icon=VRCX Icon=VRCX
Type=Application Type=Application
Categories=Network;InstantMessaging;Game; Categories=Network;InstantMessaging;Game;