#!/bin/bash # use for debug only. # set -x if [[ -z $1 ]] || [[ -z $WINEPREFIX ]] || [[ -z $GAMEID ]] || [[ -z $PROTONPATH ]]; then echo 'Usage: WINEPREFIX= GAMEID= PROTONPATH= ./gamelauncher.sh ' echo 'Ex:' echo 'WINEPREFIX=$HOME/Games/epic-games-store GAMEID=egs PROTONPATH="$HOME/.steam/steam/compatibilitytools.d/GE-Proton8-28" ./gamelauncher.sh "$HOME/Games/epic-games-store/drive_c/Program Files (x86)/Epic Games/Launcher/Portal/Binaries/Win32/EpicGamesLauncher.exe" "-opengl -SkipBuildPatchPrereq"' exit 1 fi if [[ $WINEPREFIX ]]; then if [[ ! -d "$WINEPREFIX" ]]; then mkdir -p "$WINEPREFIX" export PROTON_DLL_COPY="*" fi if [[ ! -d "$WINEPREFIX"/pfx ]]; then ln -s "$WINEPREFIX" "$WINEPREFIX"/pfx &> /dev/null fi if [[ ! -f "$WINEPREFIX"/tracked_files ]]; then touch "$WINEPREFIX"/tracked_files fi if [[ ! -f "$WINEPREFIX/dosdevices/" ]]; then mkdir -p "$WINEPREFIX"/dosdevices ln -s "../drive_c" "$WINEPREFIX/dosdevices/c:" &> /dev/null fi fi export PROTONPATH="$PROTONPATH" export ULWGL_ID="$GAMEID" export STEAM_COMPAT_APP_ID="0" numcheck='^[0-9]+$' if [[ $(echo $ULWGL_ID | cut -d "-" -f 2) =~ $numcheck ]]; then export STEAM_COMPAT_APP_ID=$(echo $ULWGL_ID | cut -d "-" -f 2) fi export SteamAppId="$STEAM_COMPAT_APP_ID" export SteamGameId="$STEAM_COMPAT_APP_ID" # TODO: Ideally this should be the main game install path, which is often, but not always the path of the game's executable. if [[ -z $STEAM_COMPAT_INSTALL_PATH ]]; then exepath="$(readlink -f "$1")" gameinstallpath="${exepath%/*}" export STEAM_COMPAT_INSTALL_PATH="$gameinstallpath" fi compat_lib_path=$(findmnt -T "$STEAM_COMPAT_INSTALL_PATH" | tail -n 1 | awk '{ print $1 }') if [ "$compat_lib_path" != "/" ]; then export STEAM_COMPAT_LIBRARY_PATHS="${STEAM_COMPAT_LIBRARY_PATHS:+"${STEAM_COMPAT_LIBRARY_PATHS}:"}$compat_lib_path" fi if [[ -z $STEAM_RUNTIME_LIBRARY_PATH ]]; then # The following info taken from steam ~/.local/share/ubuntu12_32/steam-runtime/run.sh host_library_paths= exit_status=0 ldconfig_output=$(/sbin/ldconfig -XNv 2> /dev/null; exit $?) || exit_status=$? if [[ $exit_status != 0 ]]; then echo "Warning: An unexpected error occurred while executing \"/sbin/ldconfig -XNv\", the exit status was $exit_status" fi while read -r line; do # If line starts with a leading / and contains :, it's a new path prefix if [[ "$line" =~ ^/.*: ]] then library_path_prefix=$(echo "$line" | cut -d: -f1) host_library_paths=$host_library_paths$library_path_prefix: fi done <<< "$ldconfig_output" host_library_paths="${LD_LIBRARY_PATH:+"${LD_LIBRARY_PATH}:"}$host_library_paths" steam_runtime_library_paths="${STEAM_COMPAT_INSTALL_PATH}:${host_library_paths}" export STEAM_RUNTIME_LIBRARY_PATH="$steam_runtime_library_paths" fi if [[ -z $PROTON_VERB ]]; then export PROTON_VERB="waitforexitandrun" fi export STEAM_COMPAT_CLIENT_INSTALL_PATH='' export STEAM_COMPAT_DATA_PATH="$WINEPREFIX" export STEAM_COMPAT_SHADER_PATH="$STEAM_COMPAT_DATA_PATH"/shadercache export PROTON_CRASH_REPORT_DIR='/tmp/ULWGL_crashreports' export FONTCONFIG_PATH='' export EXE="$1" if [[ "$EXE" == "createprefix" ]]; then # Hack, leave empty. # forces proton to create a prefix without actually running anything. EXE="" fi shift 1 me="$(readlink -f "$0")" here="${me%/*}" export STEAM_COMPAT_TOOL_PATHS="$PROTONPATH:$here" export STEAM_COMPAT_MOUNTS="$PROTONPATH:$here" "$here"/ULWGL "--verb=$PROTON_VERB" -- "$PROTONPATH"/proton "$PROTON_VERB" "$EXE" "$@"