Improve SteamOS/GPU detection and Linux packaging
Enhances GPU flag handling for SteamOS and Gamescope by adding early detection and flag injection in main.js. Updates the README with clearer SteamOS instructions, adds a SteamOS-optimized .desktop file, and improves Linux packaging options in package.json for AppImage and deb targets with appropriate flags and metadata.
This commit is contained in:
@@ -1,3 +1,66 @@
|
||||
// ============================================================================
|
||||
// CRITICAL: GPU flags must be applied BEFORE Electron loads
|
||||
// These must be at the VERY TOP of main.js for packaged apps
|
||||
// ============================================================================
|
||||
if (process.platform === 'linux') {
|
||||
const fs = require('fs');
|
||||
|
||||
// Detect SteamOS/Gamescope environment
|
||||
let isSteamOS = false;
|
||||
try {
|
||||
if (fs.existsSync('/etc/steamos-release')) isSteamOS = true;
|
||||
else if (fs.existsSync('/usr/share/steamos/steamos.conf')) isSteamOS = true;
|
||||
else if (process.env.GAMESCOPE_WAYLAND_DISPLAY) isSteamOS = true;
|
||||
else if (process.env.SteamDeck) isSteamOS = true;
|
||||
else if (process.env.SteamAppId) isSteamOS = true;
|
||||
else if (fs.existsSync('/etc/os-release')) {
|
||||
const osRelease = fs.readFileSync('/etc/os-release', 'utf8');
|
||||
if (osRelease.includes('SteamOS') || osRelease.includes('steamos')) isSteamOS = true;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// Apply flags via app.commandLine BEFORE requiring electron
|
||||
// We need to do this via process.argv for packaged apps
|
||||
const linuxFlags = [
|
||||
'--disable-gpu-sandbox',
|
||||
'--no-sandbox',
|
||||
'--disable-dev-shm-usage'
|
||||
];
|
||||
|
||||
if (isSteamOS || process.env.GAMESCOPE_WAYLAND_DISPLAY) {
|
||||
console.log('[GPU] SteamOS/Gamescope detected at startup - applying critical flags');
|
||||
linuxFlags.push(
|
||||
'--ozone-platform=x11',
|
||||
'--disable-gpu-compositing',
|
||||
'--disable-gpu-vsync',
|
||||
'--disable-accelerated-2d-canvas',
|
||||
'--use-gl=desktop',
|
||||
'--disable-features=VizDisplayCompositor',
|
||||
'--enable-features=UseOzonePlatform'
|
||||
);
|
||||
} else {
|
||||
// General Linux - detect Wayland vs X11
|
||||
const waylandDisplay = process.env.WAYLAND_DISPLAY;
|
||||
const x11Display = process.env.DISPLAY;
|
||||
|
||||
if (waylandDisplay && !x11Display) {
|
||||
linuxFlags.push('--ozone-platform=wayland', '--enable-features=UseOzonePlatform,WaylandWindowDecorations');
|
||||
} else if (x11Display) {
|
||||
linuxFlags.push('--ozone-platform=x11');
|
||||
}
|
||||
linuxFlags.push('--disable-features=VizDisplayCompositor');
|
||||
}
|
||||
|
||||
// Add flags that aren't already present
|
||||
linuxFlags.forEach(flag => {
|
||||
const flagName = flag.split('=')[0];
|
||||
if (!process.argv.some(arg => arg.startsWith(flagName))) {
|
||||
process.argv.push(flag);
|
||||
}
|
||||
});
|
||||
}
|
||||
// ============================================================================
|
||||
|
||||
const { app, BrowserWindow, ipcMain, session, screen, shell, dialog, Menu, clipboard, webContents } = require('electron');
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
const { pathToFileURL } = require('url');
|
||||
|
||||
Reference in New Issue
Block a user