From a317657f6ce1eb3549a90a4145470d1e8a3df620 Mon Sep 17 00:00:00 2001 From: Roy <88516395+moraroy@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:25:23 -0700 Subject: [PATCH] fixed battle infinite sleep --- NonSteamLaunchers.sh | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/NonSteamLaunchers.sh b/NonSteamLaunchers.sh index 49a40eb..8359719 100755 --- a/NonSteamLaunchers.sh +++ b/NonSteamLaunchers.sh @@ -1574,7 +1574,7 @@ if [[ $options == *"Battle.net"* ]]; then fi # Change working directory to Proton's - cd $proton_dir + cd "$proton_dir" # Set the STEAM_COMPAT_CLIENT_INSTALL_PATH environment variable export STEAM_COMPAT_CLIENT_INSTALL_PATH="${logged_in_home}/.local/share/Steam" @@ -1582,32 +1582,37 @@ if [[ $options == *"Battle.net"* ]]; then # Set the STEAM_COMPAT_DATA_PATH environment variable for Epic Games Launcher export STEAM_COMPAT_DATA_PATH="${logged_in_home}/.local/share/Steam/steamapps/compatdata/${appid}" - # Download BATTLE file + # Download BATTLE file if not already present if [ ! -f "$battle_file" ]; then echo "Downloading BATTLE file" - wget $battle_url -O $battle_file + wget "$battle_url" -O "$battle_file" fi # Run the BATTLE file using Proton with the /passive option echo "Running BATTLE file using Proton with the /passive option" - "$STEAM_RUNTIME" "$proton_dir/proton" run "$battle_file" Battle.net-Setup.exe --lang=enUS --installpath="C:\Program Files (x86)\Battle.net" - wait - # Run the BATTLE file using Proton with the /passive option - echo "Running BATTLE file using Proton with the /passive option" "$STEAM_RUNTIME" "$proton_dir/proton" run "$battle_file" Battle.net-Setup.exe --lang=enUS --installpath="C:\Program Files (x86)\Battle.net" + # Wait for the process to finish or timeout after a certain number of attempts + max_attempts=10 + attempt=0 while true; do - if pgrep -f "Battle.net.exe" > /dev/null; then - pkill -f "Battle.net.exe" - break - fi - sleep 1 + if pgrep -f "Battle.net.exe" > /dev/null; then + pkill -f "Battle.net.exe" + break + fi + sleep 1 + ((attempt++)) + if [ "$attempt" -ge "$max_attempts" ]; then + echo "Timeout: Battle.net process did not terminate." + break + fi done - fi wait + + echo "80" echo "# Downloading & Installing Amazon Games...please wait..."