Skip to content

Commit

Permalink
Fix wrong CWD on protontricks subshell startup
Browse files Browse the repository at this point in the history
- the newest beta versions of protontricks (and subsequent versions) no
  longer start up their subshells in the game's directory, but in the
  directory where protontricks was invoked
  - the script was depending on that old behavior in a few places, so
    now it explicitly sets the CWD using the (previously undocumented)
    `$STEAM_APP_PATH` env variable that's set by the subshell
  • Loading branch information
Macitron committed Sep 16, 2024
1 parent f268fb2 commit 419fa1d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions polyversal
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,14 @@ function set_game() {
esac
log_debug "ptx setup subshell finished, ptx_cmd = '$ptx_cmd'"

if ! gamedir=$($ptx_cmd -c 'pwd' $appid); then
if ! gamedir=$($ptx_cmd -c 'printf "%s" "$STEAM_APP_PATH"' $appid); then
# protontricks outputs to stdout even in the case of an error, so $gamedir actually has the error message.
printf '%s\n' "$gamedir" >&2
log_fatal "protontricks error while getting $gamecode game directory. likely is not installed or has not been run to generate prefix."
log_fatal "output of protontricks command: '$gamedir'"
zenity_error "Unable to locate $gamename's game directory. This likely means you have not yet run and quit the game once to generate its Proton prefix."
exit 99
fi
log_info "using game directory '$gamedir'"
}

# CHN CoZ patch includes custom SteamGrid images, but since the patch is built for
Expand Down Expand Up @@ -757,7 +758,9 @@ function uninstall_patch() {
exit 1
fi

local ptx_winecmd="$ptx_cmd -c '$compat_mts wine $uninstall_exe' $appid"
# $STEAM_APP_PATH is an env variable set by protontricks when it spawns its subshell, so we have to escape the $ lest
# it be interpreted by this script and always evaluate to empty
local ptx_winecmd="$ptx_cmd -c 'cd \"\$STEAM_APP_PATH\" && $compat_mts wine $uninstall_exe' $appid"
if $mode_filelog; then
ptx_winecmd+=" > ${logname}-wine.log 2>&1"
fi
Expand Down

0 comments on commit 419fa1d

Please sign in to comment.