Skip to content

[Linux] Search for Proton on all steam libraries #1369

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
May 25, 2022
Merged
Show file tree
Hide file tree
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
21 changes: 6 additions & 15 deletions electron/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
userHome,
isFlatpak,
isMac,
isWindows
isWindows,
getSteamLibraries
} from './constants'
import { execAsync } from './utils'
import { logError, logInfo, LogPrefix } from './logger/logger'
Expand Down Expand Up @@ -241,15 +242,7 @@ abstract class GlobalConfig {

const protonPaths = [`${heroicToolsPath}/proton/`]

// Known places where Steam might be found.
// Just add a new string here in case another path is found on another distro.
const steamPaths = [
join(userHome, '.steam'),
join(userHome, '.var/app/com.valvesoftware.Steam/.local/share/Steam'),
'/usr/share/steam'
].filter((path) => existsSync(path))

steamPaths.forEach((path) => {
getSteamLibraries().forEach((path) => {
protonPaths.push(`${path}/steam/steamapps/common`)
protonPaths.push(`${path}/steamapps/common`)
protonPaths.push(`${path}/root/compatibilitytools.d`)
Expand All @@ -262,11 +255,9 @@ abstract class GlobalConfig {
protonPaths.forEach((path) => {
if (existsSync(path)) {
readdirSync(path).forEach((version) => {
const name = version.toLowerCase()
const hasProtonName =
name.startsWith('proton') || name.startsWith('ge-proton')
if (hasProtonName && !name.includes('runtime')) {
const protonBin = join(path, version, 'proton')
const protonBin = join(path, version, 'proton')
// check if bin exists to avoid false positives
if (existsSync(protonBin)) {
proton.add({
bin: protonBin,
name: `Proton - ${version}`,
Expand Down
29 changes: 27 additions & 2 deletions electron/constants.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { homedir, platform } from 'os'
import { join } from 'path'
import Store from 'electron-store'
import { parse } from '@node-steam/vdf'

import { GameConfigVersion, GlobalConfigVersion } from './types'
import { createNewLogFileAndClearOldOnces } from './logger/logger'
import {
createNewLogFileAndClearOldOnces,
logDebug,
LogPrefix
} from './logger/logger'
import { env } from 'process'
import { app } from 'electron'
import { existsSync } from 'graceful-fs'
import { existsSync, readFileSync } from 'graceful-fs'

const configStore = new Store({
cwd: 'store'
Expand Down Expand Up @@ -109,6 +114,26 @@ function getSteamCompatFolder() {
return `${userHome}/.steam/steam`
}

export function getSteamLibraries(): string[] {
const vdfFile = join(steamCompatFolder, 'steamapps', 'libraryfolders.vdf')
const libraries = ['/usr/share/steam']

if (existsSync(vdfFile)) {
const json = parse(readFileSync(vdfFile, 'utf-8'))
const folders = Object.values(json.libraryfolders) as Array<{
path: string
}>
return [...libraries, ...folders.map((folder) => folder.path)].filter(
(path) => existsSync(path)
)
}
logDebug(
'Unable to load Steam Libraries, libraryfolders.vdf not found',
LogPrefix.Backend
)
return libraries
}

const MAX_BUFFER = 25 * 1024 * 1024 // 25MB should be safe enough for big installations even on really slow internet

const execOptions = {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"@fortawesome/react-fontawesome": "^0.1.18",
"@mui/icons-material": "^5.6.2",
"@mui/material": "^5.6.2",
"@node-steam/vdf": "^2.2.0",
"axios": "^0.26.1",
"check-disk-space": "^3.3.0",
"classnames": "^2.3.1",
Expand Down
Loading