Skip to content

[Fix] Ignore gamescope if enabled and not found instead of failing #3367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 64 additions & 66 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down