#!/usr/bin/bash

SELF=$(readlink -f "$0")
LIBWINE=$(dirname $SELF)/../lib

export PATH=$(dirname $SELF):$PATH
export WINEDLLPATH=${LIBWINE}
export WINE_ADD_HOTKEY_SCRIPT=$(dirname $SELF)/add_hotkey.py

if [ ! -z "$APPSTARTCHECK" ]; then
    if [[ "$APPSTARTCHECK" =~ ^[0-9]+$ ]]; then
        # 执行 start-check 并传递超时参数
        start-check -t "$APPSTARTCHECK" -k "$@"
        result=$?
        if [ $result -ne 0 ]; then
            exit 1
        fi
    fi
fi

if command -v box86 >/dev/null 2>&1 && [ "$(arch)" = "aarch64" ]; then
. box86_64.env
else
. x86_64.env
fi

ulimit -n 100000 &> /dev/null
exec wine "$@"

