Spiele starten unter Linux

mytosh

Lt. Commander Pro
Registriert
Feb. 2022
Beiträge
1.176
Hallo Freunde,

in letzter Zeit, sind ja ein paar mehr Linux Nutzer gespawnt.
Also dachte ich mir, es macht vielleicht Sinn, die mal ein wenig abzuholen.

Ich lese oftmals davon, dass es manchen nicht gelingt, Spiele, ausserhalb von Steam oder Heroic, zu starten.

Deshalb wollte ich mal ein paar Skripte mit euch teilen.

Das Erste wäre einfach nur ein Proton Startskript aus dem AUR.
Code:
#!/bin/bash

## configuration
# proton executable
_proton="$HOME/Games/Proton/Proton-CachyOS Latest/proton"
# default prefix dir if STEAM_COMPAT_DATA_PATH not set
_pfx=${XDG_DATA_HOME:-~/.local/share}/proton-cachy
# default dxvk state cache path if not set, could be compatible with dxvk-cache-pool application
_cachepath=${XDG_CACHE_HOME:-~/.cache}/dxvk-cache-pool
# default appid if STEAM_COMPAT_DATA_PATH or SteamAppId not set nor given as an argument
_appid=0
# default mode of execution if not given as an argument
_mode=waitforexitandrun
# default steam install path (don't worry, you still don't need steam)
_steam=${XDG_DATA_HOME:-~/.local/share}/Steam

## functions
set_env() {
    # Proton now cares about steam install - it wants to update the tracked files according to installed steam.
    # While this makes no sense in standalone, we need to set *some* path even if does not exists.
    if [ -z ${STEAM_COMPAT_CLIENT_INSTALL_PATH+x} ]; then
        export STEAM_COMPAT_CLIENT_INSTALL_PATH=${_steam}
        >&2 echo "ProtonLauncher[$$] INFO: empty STEAM_COMPAT_CLIENT_INSTALL_PATH set to ${STEAM_COMPAT_CLIENT_INSTALL_PATH}"
    fi
    if ! [ -d "${STEAM_COMPAT_CLIENT_INSTALL_PATH}" ]; then
        >&2 echo "ProtonLauncher[$$] WARN: directory ${STEAM_COMPAT_CLIENT_INSTALL_PATH} does not exist"
    fi

    # No data path to prefix? Let's set the default path. We want to include the AppId in the path like steam.
    if [ -z ${STEAM_COMPAT_DATA_PATH+x} ]; then
        export STEAM_COMPAT_DATA_PATH=${_pfx}/${SteamAppId:-${_appid}}
        >&2 echo "ProtonLauncher[$$] INFO: empty STEAM_COMPAT_DATA_PATH set to ${STEAM_COMPAT_DATA_PATH}"
    elif ! [ "${SteamGameId}" -ge 0 ] 2>/dev/null && ! [ "${SteamAppId}" -ge 0 ] 2>/dev/null && ! [ "$(basename "${STEAM_COMPAT_DATA_PATH}")" -ge 0 ] 2>/dev/null; then
        export SteamAppId=${_appid}
        >&2 echo "ProtonLauncher[$$] INFO: empty SteamAppId set to ${SteamAppId}"
    fi
    # If the prefix path does not exist yet, we will create it.
    if ! [ -d "${STEAM_COMPAT_DATA_PATH}" ]; then
        install -d "${STEAM_COMPAT_DATA_PATH}" || exit 1
        >&2 echo "ProtonLauncher[$$] INFO: directory ${STEAM_COMPAT_DATA_PATH} created"
    fi

    # DXVK state cache path not given, we will use a default.
    if [ -z ${DXVK_STATE_CACHE_PATH+x} ]; then
        export DXVK_STATE_CACHE_PATH=${_cachepath}
        >&2 echo "ProtonLauncher[$$] INFO: empty DXVK_STATE_CACHE_PATH set to ${_cachepath}"
    fi
    # If the state cache path does not exist yet, we will create it.
    if ! [ -d "${DXVK_STATE_CACHE_PATH}" ]; then
        install -d "${DXVK_STATE_CACHE_PATH}" || exit 1
        >&2 echo "ProtonLauncher[$$] INFO: directory ${DXVK_STATE_CACHE_PATH} created"
    fi

    # Placeholder in case we need the workaround again when tracked_files missing
    if ! [ -f "${STEAM_COMPAT_DATA_PATH}"/tracked_files ]; then
        if [ -f "${STEAM_COMPAT_DATA_PATH}"/version ]; then
            >&2 echo "ProtonLauncher[$$] WARN: file ${STEAM_COMPAT_DATA_PATH}/tracked_files missing! Please report to AUR maintainer"
        fi
    fi

    # argument -e was provided, so summarize the relevant env we set so far.
    if [ "${_printenv}" == "true" ] 2>/dev/null; then print_env; fi
}

print_usage() {
    cat <<EOF

USAGE:  proton [--environment|-e] executable.exe
        proton [--environment|-e] [mode]  executable.exe
        proton [--environment|-e] [appid] executable.exe
        proton [--help|-h]

EOF
}

print_help() {
    print_usage
    cat <<EOF
ENV:    STEAM_COMPAT_DATA_PATH
        STEAM_COMPAT_CLIENT_INSTALL_PATH
        DXVK_STATE_CACHE_PATH
        SteamAppId
        SteamGameId

Just call this proton launcher script with your app as the only argument
to run it with the default prefix
${_pfx}/${_appid} and default mode "${_mode}".

Use other invocations as stated with USAGE: and/or modify behavior with
environment variables as described below.

_mode_

You can change the mode of operation by specifying it as the first argument.
Possible values are: waitforexitandrun, run, getcompatpath, getnativepath

_appid_

Protonfixes (included by proton-ge) uses three environment variables to
determine the application to run fixes for.
The env STEAM_COMPAT_DATA_PATH points to the wine prefix and usually includes
the AppId, which is used in that case. If the env SteamAppId (or SteamGameId)
is set, it takes precedence as the AppId used by protonfixes.

As proton itself needs the env STEAM_COMPAT_DATA_PATH set, the default prefix
${_pfx}/${_appid} is used when it is not set or empty.
In that case, an AppId given by env SteamAppId or as the first argument will
alter this path accordingly.
If STEAM_COMPAT_DATA_PATH is set, it will not be modified by a provided AppId.

Provide "appid" as the first argument to change the AppId regardless of
the env vars (force). In this case, the mode defaults to "${_mode}".
Useable for "appid": see https://steamdb.info/apps/

_other_

The env STEAM_COMPAT_CLIENT_INSTALL_PATH is set to "${_steam}" if not given,
because proton cares. It has no effect if proton is not started from
within steam anyway, therefore the path does not have to be actually resolvable.

DXVK creates cache files right next to the executable if the env
DXVK_STATE_CACHE_PATH is missing.
This launcher sets it to "${_cachepath}"
if not provided. It makes sharing of those files as well as read-only game
folders possible. Also, the cache survives remove/reinstall of the game.

You may share oder download caches for example from here:
https://github.com/begin-theadventure/dxvk-caches/

Note that the env SteamGameId is not set by this launcher script in any case.
This env is evaluated by steam executables inside the prefix. Set it yourself
if you see fit.

To print the current env when this script is called, use the "-e" switch.

_example invocations_

# "${_mode}" winecfg in prefix ${_pfx}/${_appid}
$ proton winecfg

# "${_mode}" winecfg in prefix ${_pfx}/${_appid}, dump all env that have been set
$ proton -e winecfg

# "${_mode}" winecfg in prefix ${_pfx}/17330, matching protonfixes for crysis are run
$ proton 17300 winecfg

# returns native path in ${_pfx}/${_appid}
$ proton getnativepath "C:\Windows"

# "${_mode}" winecfg in prefix ~/myfolder/17300, matching protonfixes for crysis are run
$ env STEAM_COMPAT_DATA_PATH=~/myfolder/17300 proton winecfg

EOF
}

print_env() {
cat <<EOF

Current ENVIRONMENT variables:

STEAM_COMPAT_CLIENT_INSTALL_PATH  ${STEAM_COMPAT_CLIENT_INSTALL_PATH:-"Empty or not set."}
STEAM_COMPAT_DATA_PATH            ${STEAM_COMPAT_DATA_PATH:-"Empty or not set."}
DXVK_STATE_CACHE_PATH             ${DXVK_STATE_CACHE_PATH:-"Empty or not set."}
SteamAppId                        ${SteamAppId:-"Empty or not set."}
SteamGameId                       ${SteamGameId:-"Empty or not set."}
EOF
}

## main
if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
    print_help
    exit 0
fi
if [ "$1" == "--environment" ] || [ "$1" == "-e" ]; then
    _printenv=true
    shift
fi

case $# in
0)
    print_usage
    ;;
1)
    # just start an application with default appid and mode
    set_env
    "${_proton}" "${_mode}" "$1"
    ;;
*)
    if ! [ "$1" -ge 0 ] 2>/dev/null; then
        # start proton with given arguments, compatible with standard proton invocation
        set_env
        "${_proton}" "${@}"
    else
        # first arg is a positive signed int, thus the appid
        export SteamAppId="$1"
        #export SteamGameId="$1"
        >&2 echo "ProtonLauncher[$$] INFO: forcing SteamAppId to $1"
        set_env
        "${_proton}" "${_mode}" "${@:2}"
    fi
    ;;
esac

Das speichert man einfach und macht es ausführbar.
Möglicherweie, müsst ihr je nach Distro abhängigkeiten installieren.
Ich habe es schon erfolgreich unter Debian verwendet.
Code:
sudo chmod +x /usr/bin/proton

In meiner angepassten Version, geht der Link zu Proton-Cachy auf:
_proton="$HOME/Games/Proton/Proton-CachyOS Latest/proton"
ODER für Proton-GE
_proton="$HOME/Games/Proton/Proton-GE Latest/proton"
Das Prefix wäre hier:
_pfx=${XDG_DATA_HOME:-~/.local/share}/proton

In Verbindung mit protonplus, kann man sich den Ordner
~/.steam/steam/compatibilitytools.d/ Ordner zB auf ~/Games/Proton/
verlinken.

Vorher die Ordner anlegen.
Code:
mkdir -p ~/Games/Proton
Alles verschieben
Code:
mv ~/.steam/steam/compatibilitytools.d/* ~/Games/Proton/
den Ordner löschen
Code:
rm -rf ~/.steam/steam/compatibilitytools.d
und anschließend verlinken
Code:
ln -s ~/Games/Proton ~/.steam/steam/compatibilitytools.d

Nun würde protonplus nach ~/Games/Proton herunterladen, Steam könnte die Versionen nutzen
und ihr habt das aktuellste Proton-GE oder Proton-Cachy oder welche auch immer.

Das wäre der erste Streich.
Weiterhin nutze ich
Code:
#!/bin/bash

choice=$(zenity --list \
  --title="EXE starten" \
  --text="Bitte wähle eine Option:" \
  --column="" \
  "Wine" \
  "Proton")

[ -z "$choice" ] && exit 1

if [ $# -eq 0 ]; then
  zenity --error --text="Keine Datei angegeben"
  exit 1
fi

datei="$1"
absoluter_pfad=$(realpath "$datei" 2>/dev/null || readlink -f "$datei" 2>/dev/null)
cd "$(dirname "$absoluter_pfad")" || exit 1

# Gemeinsame Variablen
  COMMON_VARS=(
  MANGOHUD=1
  PROTON_USE_OPTISCALER=1
  PROTON_OPTISCALER_NAME=winmm.dll
  PROTON_FSR4_RDNA3_UPGRADE=4.0.2
  PROTON_FSR4_UPGRADE=1
  PROTON_XESS_UPGRADE=1
  RADV_PERFTEST="aco,gpl,sam,nggc,dfsm,localbos,bolist,shader_object"
  RADV_ZERO_VRAM=false
  RADV_REBAR=1
  RADV_TEX_ANISO=16
  RADV_FORCE_VRS=1
  RADV_EXPERIMENTAL=hic
  ENABLE_LAYER_MESA_ANTI_LAG=1
  DXIL_SPIRV_CONFIG=wmma_rdna3_workaround
  MESA_SHADER_CACHE_MAX_SIZE=12G
  PROTON_ENABLE_NTSYNC=1
  PROTON_ENABLE_WAYLAND=1
  PROTON_ENABLE_HDR=1
  PROTON_ENABLE_MEDIACONV=1
  PROTON_LOCAL_SHADER_CACHE=1
  PROTON_NO_WM_DECORATION=1
  PROTON_ENABLE_NVAPI=0
  PROTON_LOG=0
  WINEDLLOVERRIDES="winmm=n,b"
  WINEDLLOVERRIDES=\"winmm=n,b\"
  )

# Variablen exportieren
export "${COMMON_VARS[@]}"

case "$choice" in
  "Wine")
    gamemoderun wine "$1"
    ;;
  "Proton")
    gamemoderun /usr/bin/proton "$1"
    ;;
esac
Code:
sudo chmod +x /usr/bin/proton_launcher

Damit starte ich meine Spiele einfach per Doppleklick.
Zenity, welches installiert sein muss, zeigt einem daraufhin eine Auswahl, ob mit wine oder proton gestartet werden soll.
Installationen von ISO's starte ich zB immer mit wine anstatt proton.

Unter COMMON_VARS, können Tinker Steps mitgegeben werden.
In meinem Beispiel sind es möglicherweise ein paar viele aber ich Pflege das auch
nur alle Jubeljahre.

Dieses Skript ist für AMD optimiert.
Solltet ihr nvidia nutzen müsst ihr definitiv die COMMON_VARS bearbeiten.

Das letzte Skript, welches ich als Hotkey auf F12 habe, wäre
Code:
#!/bin/bash
pgrep -f '.*\.exe' | while read -r pid; do
  pkill -TERM -P "$pid"
  kill -9 "$pid"
done

Code:
sudo chmod +x /usr/bin/winekill
Dieses Skript tötet zuverlässig alle wine / proton Prozesse.

Es macht ausserdem Sinn, die user Ordner im Prefix selbst anderswo zu beheimaten.
Bei mir wäre das alles (AppData, SavedGames etc.) unter ~/Dokumente.
Bitte nich blindlinks ausführen, solltet ihr gewisse Ordner bereits haben, wären eure Spielstände weg.
Code:
USER_NAME="$(whoami)"
PFX="$HOME/.local/share/proton-pfx/0/pfx/drive_c/users"

mkdir -p \
  "$HOME/Dokumente/AppData" \
  "$HOME/Dokumente/Application Data" \
  "$HOME/Saved Games" \
  "$HOME/Downloads"

ln -sfn "$PFX/steamuser" "$PFX/$USER_NAME"

rm -rf \
  "$PFX/steamuser/AppData" \
  "$PFX/steamuser/Application Data" \
  "$PFX/steamuser/Saved Games" \
  "$PFX/steamuser/Documents" \
  "$PFX/steamuser/Downloads"

ln -sfn "$HOME/Dokumente/AppData" "$PFX/steamuser/AppData"
ln -sfn "$HOME/Dokumente/Application Data" "$PFX/steamuser/Application Data"
ln -sfn "$HOME/Saved Games" "$PFX/steamuser/Saved Games"
ln -sfn "$HOME/Dokumente" "$PFX/steamuser/Documents"
ln -sfn "$HOME/Downloads" "$PFX/steamuser/Downloads"

mkdir -p "$HOME/.local/share/proton-pfx_ex/0/pfx/drive_c"
mkdir -p "$HOME/.local/share/proton-pfx-cachy/0/pfx/drive_c"

ln -sfn "$PFX" "$HOME/.local/share/proton-pfx_ex/0/pfx/drive_c/users"
ln -sfn "$PFX" "$HOME/.local/share/proton-pfx-cachy/0/pfx/drive_c/users"
Code:
sudo chmod +x /usr/bin/proton_pfx
/usr/bin/proton_pfx

Solltet ihr nun das Prefix, aus welchen Gründen auch immer mal löschen müssen, würde
/usr/bin/proton_pfx eure Userdaten also wiederherstellen.

Mehr fällt mir gerade nicht ein also Ende.
Schönes Wochenende.
 
  • Gefällt mir
Reaktionen: Tommy64, CeeSA, SaPa und 7 andere
Außerhalb von Steam, Heroic und anderen Launchern nutze ich einfach Lutris. Aus dem Store installieren, links oben auf das kleine + Symbol klicken und man kann alles Menü gesteuert mit der Maus erledigen. Spiele von CD/DVD oder Archiven installieren ist mit Lutris selbsterklärend und kein Problem. Man kann auch Protonversionen und Start-Verzeichnisse anpassen. Also die Start Exe-Datei mit dem Mauszeiger auswählen, wenn Lutris das nicht richtig eingestellt hat. Dauert nur wenige Sekunden.

Bottles gibt es auch noch, aber damit komme ich nicht so dolle klar, obwohl Manche darauf schwören. Die Konsole finde ich für Spiele ich eher gruselig. Wusste nicht das es damit auch funktioniert. Habe mir Deinen Beitrag für alle Fälle abgespeichert.
 
  • Gefällt mir
Reaktionen: simplyroman
@Tommy64
Kannst du natürlich weiterhin so handhaben. Für mich ist Lutris allerdings etwas zu aufwendig – ich mag es lieber unkompliziert. Ein einfacher Doppelklick auf eine .exe ist für mich meist der angenehmere Weg.
Gleiches gilt für Faugus Launcher, welchen ich maximal für die anderen Launcher/Stores nutze.
 
Zurück
Oben