#!/bin/bash
# FUSS Reader - Assistive speech reader wrapper script

# Define application and library directories
APP_DIR="/usr/share/fuss-reader"
LIB_DIR="$APP_DIR/lib"

# Set PYTHONPATH to include bundled Python modules (piper and onnxruntime)
# This allows the system Python to locate modules stored in the custom lib folder
export PYTHONPATH="$LIB_DIR:$PYTHONPATH"

# Set LD_LIBRARY_PATH for bundled shared libraries (.so files)
# - $LIB_DIR/piper: required for espeakbridge.so
# - $LIB_DIR/onnxruntime/capi: required for ONNX runtime binary components
export LD_LIBRARY_PATH="$LIB_DIR/piper:$LIB_DIR/onnxruntime/capi:$LD_LIBRARY_PATH"

# Execute the application replacing the shell process
# "$@" ensures that any command line arguments are passed to the Python script
exec python3 "$APP_DIR/main.py" "$@"
