From 00348ebff4cb9ca84ece305679a0a0ebc0f07efc Mon Sep 17 00:00:00 2001 From: Ariel Juodziukynas Date: Sat, 30 Dec 2023 20:29:30 -0300 Subject: [PATCH] Ignore gamescope if enabled and not found instead of failing --- src/backend/launcher.ts | 130 ++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/src/backend/launcher.ts b/src/backend/launcher.ts index 7ab51a9005..1dc73e6310 100644 --- a/src/backend/launcher.ts +++ b/src/backend/launcher.ts @@ -136,83 +136,81 @@ async function prepareLaunch( ) { const gameScopeBin = await searchForExecutableOnPath('gamescope') if (!gameScopeBin) { - return { - success: false, - failureReason: - 'Gamescope is enabled, but `gamescope` executable could not be found on $PATH' + logWarning( + 'Gamescope is enabled, but `gamescope` executable could not be found on $PATH' + ) + } else { + // Gamescope does not provide a version option and they changed + // cli options on version 3.12. So we do what lutris does. + let oldVersion = true // < 3.12 + const { stderr } = spawnSync(gameScopeBin, ['--help'], { + encoding: 'utf-8' + }) + if (stderr && stderr.includes('-F, --filter')) { + oldVersion = false } - } - // Gamescope does not provide a version option and they changed - // cli options on version 3.12. So we do what lutris does. - let oldVersion = true // < 3.12 - const { stderr } = spawnSync(gameScopeBin, ['--help'], { - encoding: 'utf-8' - }) - if (stderr && stderr.includes('-F, --filter')) { - oldVersion = false - } + gameScopeCommand.push(gameScopeBin) - gameScopeCommand.push(gameScopeBin) + if (gameSettings.gamescope.enableUpscaling) { + // game res + if (gameSettings.gamescope.gameWidth) { + gameScopeCommand.push('-w', gameSettings.gamescope.gameWidth) + } + if (gameSettings.gamescope.gameHeight) { + gameScopeCommand.push('-h', gameSettings.gamescope.gameHeight) + } - if (gameSettings.gamescope.enableUpscaling) { - // game res - if (gameSettings.gamescope.gameWidth) { - gameScopeCommand.push('-w', gameSettings.gamescope.gameWidth) - } - if (gameSettings.gamescope.gameHeight) { - gameScopeCommand.push('-h', gameSettings.gamescope.gameHeight) - } + // gamescope res + if (gameSettings.gamescope.upscaleWidth) { + gameScopeCommand.push('-W', gameSettings.gamescope.upscaleWidth) + } + if (gameSettings.gamescope.upscaleHeight) { + gameScopeCommand.push('-H', gameSettings.gamescope.upscaleHeight) + } - // gamescope res - if (gameSettings.gamescope.upscaleWidth) { - gameScopeCommand.push('-W', gameSettings.gamescope.upscaleWidth) - } - if (gameSettings.gamescope.upscaleHeight) { - gameScopeCommand.push('-H', gameSettings.gamescope.upscaleHeight) - } + // upscale method + if (gameSettings.gamescope.upscaleMethod === 'fsr') { + oldVersion + ? gameScopeCommand.push('-U') + : gameScopeCommand.push('-F', 'fsr') + } + if (gameSettings.gamescope.upscaleMethod === 'nis') { + oldVersion + ? gameScopeCommand.push('-Y') + : gameScopeCommand.push('-F', 'nis') + } + if (gameSettings.gamescope.upscaleMethod === 'integer') { + oldVersion + ? gameScopeCommand.push('-i') + : gameScopeCommand.push('-S', 'integer') + } + // didn't find stretch in old version + if (gameSettings.gamescope.upscaleMethod === 'stretch' && !oldVersion) { + gameScopeCommand.push('-S', 'stretch') + } - // upscale method - if (gameSettings.gamescope.upscaleMethod === 'fsr') { - oldVersion - ? gameScopeCommand.push('-U') - : gameScopeCommand.push('-F', 'fsr') - } - if (gameSettings.gamescope.upscaleMethod === 'nis') { - oldVersion - ? gameScopeCommand.push('-Y') - : gameScopeCommand.push('-F', 'nis') - } - if (gameSettings.gamescope.upscaleMethod === 'integer') { - oldVersion - ? gameScopeCommand.push('-i') - : gameScopeCommand.push('-S', 'integer') - } - // didn't find stretch in old version - if (gameSettings.gamescope.upscaleMethod === 'stretch' && !oldVersion) { - gameScopeCommand.push('-S', 'stretch') + // window type + if (gameSettings.gamescope.windowType === 'fullscreen') { + gameScopeCommand.push('-f') + } + if (gameSettings.gamescope.windowType === 'borderless') { + gameScopeCommand.push('-b') + } } - // window type - if (gameSettings.gamescope.windowType === 'fullscreen') { - gameScopeCommand.push('-f') - } - if (gameSettings.gamescope.windowType === 'borderless') { - gameScopeCommand.push('-b') + if (gameSettings.gamescope.enableLimiter) { + if (gameSettings.gamescope.fpsLimiter) { + gameScopeCommand.push('-r', gameSettings.gamescope.fpsLimiter) + } + if (gameSettings.gamescope.fpsLimiterNoFocus) { + gameScopeCommand.push('-o', gameSettings.gamescope.fpsLimiterNoFocus) + } } - } - if (gameSettings.gamescope.enableLimiter) { - if (gameSettings.gamescope.fpsLimiter) { - gameScopeCommand.push('-r', gameSettings.gamescope.fpsLimiter) - } - if (gameSettings.gamescope.fpsLimiterNoFocus) { - gameScopeCommand.push('-o', gameSettings.gamescope.fpsLimiterNoFocus) - } + // Note: needs to be the last option + gameScopeCommand.push('--') } - - // Note: needs to be the last option - gameScopeCommand.push('--') } // If the Steam Runtime is enabled, find a valid one