Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env zsh
- ######################
- ##### EDIT THIS: #####
- ######################
- local GW2_PATH="$HOME/.wine/drive_c/Program Files/Guild Wars 2"
- ####################################
- ##### DON'T EDIT BELOW HERE ^^ #####
- ####################################
- # Variables:
- local CNT=0
- local CRASH_CHECK
- local CRASH_WINDOW
- local UPDATED=0
- local WINEDEBUG
- # Time between checks. Easy to edit.
- local TIME_CHECKS=10
- # Before anything... Check if xdotool is avaible.
- if [[ ! $(command -v xdotool) ]]; then
- print "This script requires xdotool to work properly. Aborting."
- return -1
- fi
- # Enter Gw2's directory:
- cd $GW2_PATH
- # Let's print a stat message:
- print "Guild Wars 2 updater running. Press ctrl+c to stop it."
- # We'll keep doing this until Gw2 has been updated.
- while [[ $UPDATED == 0 ]]; do
- # Ok, we start Gw2 so it can update.
- WINEDEBUG=-all wine Gw2.exe -dx9single -image &
- # Keep track of the number of iterations:
- CNT=$(($CNT + 1))
- print "Iteration $CNT..."
- # Let's wait the default time vefore starting the checks.
- sleep $TIME_CHECKS
- # Set the check variable for the loop
- CRASH_CHECK=0
- # As long as Gw2.exe is running, we'll keep checking:
- while [[ ! "$(pidof Gw2.exe)" == "" ]]; do
- # Ok, Gw2.exe is running. Did it crash?
- CRASH_WINDOW=$(xdotool search --name "Gw2.exe")
- if [[ ! $CRASH_WINDOW == "" ]]; then
- # Ok, it crashed, so...
- # 1. Let's close the crash report window.
- xdotool windowfocus $CRASH_WINDOW
- xdotool key Escape
- # 2. Let's note that it did crash.
- CRASH_CHECK=1
- else
- # It didn't crash, so it's still updating! Let's give it some time...
- sleep $TIME_CHECKS
- fi
- done
- # At this point, no wineserver should be running. But just in case...
- sleep 3
- sync
- wineserver -k
- # Update check: Gw2.exe isn't running. Did it crash or did it update correctly?
- if [[ $CRASH_CHECK == 0 ]]; then
- # Gw2 updated succesfully!
- UPDATED=1
- fi
- done
- # Unset variables
- unset CNT CRASH_CHECK CRASH_WINDOW UPDATED WINEDEBUG TIME_CHECKS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement