in Linux steamclient_loader, expand exe and steam runtime exe when provided, this is because we cd before running, and the given relative path will no longer be valid + some fixes after testing it

This commit is contained in:
otavepto 2023-12-26 23:53:50 +02:00
parent 071925106b
commit 8997c70ac6

View File

@ -60,6 +60,7 @@ fi
# no args = help page # no args = help page
if [[ $# = 0 ]]; then if [[ $# = 0 ]]; then
echo "[?] No arguments provided"
help_page help_page
exit 0 exit 0
fi fi
@ -123,26 +124,33 @@ done
# prepending the script dir helps sudo users when for example EXE=./mygame # prepending the script dir helps sudo users when for example EXE=./mygame
[[ -f "$EXE" ]] || EXE="$script_dir/$EXE" [[ -f "$EXE" ]] || EXE="$script_dir/$EXE"
if [[ ! -f "$EXE" ]]; then if [[ ! -f "$EXE" ]]; then
echo "[X] executable was not set or not found" >&2 echo "[X] executable '$EXE' is invalid" >&2
help_page help_page
exit 1 exit 1
fi fi
if [[ "$APP_ID" =~ ^[0-9]+$ ]]; then # change to absolute path
echo "[X] app ID was not set or not a valid number" >&2 EXE="$( cd -- "$( dirname "$EXE" )" 2> /dev/null && pwd )/$( basename "$EXE" )"
if [[ ! "$APP_ID" =~ ^[0-9]+$ ]]; then
echo "[X] app ID '$APP_ID' is invalid" >&2
help_page help_page
exit 1 exit 1
fi fi
# use the exe's dir if non-specified # use the exe's dir if non-specified
[[ -z "$EXE_RUN_DIR" ]] && EXE_RUN_DIR="$(dirname "$EXE")" [[ -z "$EXE_RUN_DIR" ]] && EXE_RUN_DIR="$(dirname "$EXE")"
if [[ ! -d "$EXE_RUN_DIR" ]]; then if [[ ! -d "$EXE_RUN_DIR" ]]; then
echo "[X] executable working directory is invalid" >&2 echo "[X] executable working directory '$EXE_RUN_DIR' is invalid" >&2
help_page help_page
exit 1 exit 1
fi fi
if [[ ! -z "$STEAM_RUNTIME" ]] && [[ ! -f "$STEAM_RUNTIME" ]]; then if [[ ! -z "$STEAM_RUNTIME" ]]; then
echo "[X] Steam runtime script was set but the file was not found" >&2 if [[ ! -f "$STEAM_RUNTIME" ]]; then
echo "[X] Steam runtime script was set '$STEAM_RUNTIME', but the file was not found" >&2
help_page help_page
exit 1 exit 1
fi
# change to absolute path
STEAM_RUNTIME="$( cd -- "$( dirname "$STEAM_RUNTIME" )" 2> /dev/null && pwd )/$( basename "$STEAM_RUNTIME" )"
fi fi
# print everything # print everything
@ -197,12 +205,17 @@ echo ${$} > "$steam_base_dir/steam.pid"
# set variables and run the app # set variables and run the app
pushd "${EXE_RUN_DIR}" pushd "${EXE_RUN_DIR}"
if [ -z "${STEAM_RUNTIME}" ]; then TARGET_EXE="$EXE"
SteamAppPath="${EXE_RUN_DIR}" SteamAppId=$APP_ID SteamGameId=$APP_ID SteamOverlayGameId=$APP_ID "$EXE" "${EXE_COMMAND_LINE[@]}" if [ ! -z "${STEAM_RUNTIME}" ]; then
else TARGET_EXE="$STEAM_RUNTIME"
SteamAppPath="${EXE_RUN_DIR}" SteamAppId=$APP_ID SteamGameId=$APP_ID SteamOverlayGameId=$APP_ID "$STEAM_RUNTIME" "$EXE" "${EXE_COMMAND_LINE[@]}" EXE_COMMAND_LINE=(
"$EXE"
"${EXE_COMMAND_LINE[@]}"
)
fi fi
SteamAppPath="${EXE_RUN_DIR}" SteamAppId=$APP_ID SteamGameId=$APP_ID SteamOverlayGameId=$APP_ID "$TARGET_EXE" "${EXE_COMMAND_LINE[@]}"
popd popd
#restore backup #restore backup