#!/bin/bash set -e DIR="$(cd "$(dirname "$0")" && pwd)" VENV="$DIR/.venv" PY="$VENV/bin/python3" PIP="$VENV/bin/pip" GUI="$DIR/src/zupt_gui.py" # ─── System deps (Qt xcb needs these on Debian/Mint/Ubuntu) ─── NEED_APT=0 for pkg in libxcb-cursor0 libxcb-xinerama0 libxkbcommon-x11-0 libegl1 python3-full; do dpkg -s "$pkg" >/dev/null 2>&1 || NEED_APT=1 done if [ "$NEED_APT" -eq 1 ]; then echo "Installing system dependencies..." sudo apt-get update -qq sudo apt-get install -y python3-full python3-venv \ libxcb-cursor0 libxcb-xinerama0 libxkbcommon-x11-0 libegl1 2>/dev/null fi # ─── Venv ─── if [ ! -x "$PY" ]; then rm -rf "$VENV" python3 -m venv "$VENV" fi if ! "$PY" -c "import PySide6" 2>/dev/null; then echo "Installing PySide6..." "$PIP" install --upgrade pip -q 2>/dev/null "$PIP" install PySide6 -q fi # ─── Find zupt — local build FIRST, then system ─── if [ -z "$ZUPT_BIN" ]; then # Check project tree first (gui/ is inside zupt-2.1.6/) for p in "$DIR/../zupt" "$DIR/../../zupt" "$DIR/zupt"; do [ -x "$p" ] && export ZUPT_BIN="$(readlink -f "$p")" && break done # Then system PATH if [ -z "$ZUPT_BIN" ]; then p="$(command -v zupt 2>/dev/null)" [ -x "$p" ] && export ZUPT_BIN="$p" fi fi exec "$PY" "$GUI" "$@"