#!/bin/bash export DISPLAY=:0 export WINEARCH=win64 export HOME=/root export LANG=en_US.UTF-8 cd "/root/prefix32/drive_c/Program Files (x86)/AgeOfTime" sleep 5 # give the x server time to start # get current active window name # $ xdotool getactivewindow getwindowname # set age of time console as active window (reduces CPU usage) # $ xdotool search --name "AgeOfTime.exe" windowactivate # set age of time window as active window (more CPU but you can view the game) # $ xdotool search --name "Age Of Time" windowactivate # background task to minimize Age Of Time by switching # to the AgeOfTime.exe console window if [ "$AOT_MINIMIZED" == "true" ]; then ( while true; do # Check if a window with name "Age Of Time" exists # as the console window spawns first and we want to # switch back to it after the game window starts AGE_OF_TIME_WIN_ID=$(xdotool search --name "Age Of Time") if [ ! -z "$AGE_OF_TIME_WIN_ID" ]; then # Get current active window name ACTIVE_WIN_NAME=$(xdotool getactivewindow getwindowname) # If the active window is not AgeOfTime.exe, try to set it to AgeOfTime.exe if [[ "$ACTIVE_WIN_NAME" != *"AgeOfTime.exe"* ]]; then xdotool search --name "AgeOfTime.exe" windowactivate else break # Active window is AgeOfTime.exe, exit the loop fi fi sleep 1 # Wait for a second before checking again done ) & BG_TASK_PID=$! fi # Run AgeOfTime.exe with wineconsole wineconsole AgeOfTime.exe # Ensure the background task is stopped when AgeOfTime.exe quits, only if it was started if [ ! -z "$BG_TASK_PID" ] && kill -0 $BG_TASK_PID 2>/dev/null; then kill $BG_TASK_PID fi