#!/bin/sh set -eu SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) find_game_dir() { for candidate in \ "$SCRIPT_DIR" \ "$SCRIPT_DIR/mice" \ /roms/ports/mice \ /root/mice \ "$HOME/mice"; do if [ -f "$candidate/rats.py" ]; then printf '%s\n' "$candidate" return 0 fi done return 1 } find_conda() { for candidate in \ /home/ark/miniconda3/bin/conda \ /root/miniconda3/bin/conda \ "$HOME/miniconda3/bin/conda" \ /usr/bin/conda; do if [ -x "$candidate" ]; then printf '%s\n' "$candidate" return 0 fi done return 1 } detect_keybindings_profile() { if [ -f /opt/muos/device/current/config.ini ]; then board_name=$(sed -n 's/^name = //p' /opt/muos/device/current/config.ini | head -n 1 | tr '[:upper:]' '[:lower:]') case "$board_name" in *rg40xx*) printf 'rg40xx\n' return 0 ;; *r36s*) printf 'r36s\n' return 0 ;; esac fi return 1 } GAMEDIR=$(find_game_dir) CONDABIN=$(find_conda) export MICE_PROJECT_ROOT="$GAMEDIR" if [ -z "${MICE_KEYBINDINGS_PROFILE:-}" ]; then MICE_KEYBINDINGS_PROFILE=$(detect_keybindings_profile || true) export MICE_KEYBINDINGS_PROFILE fi eval "$($CONDABIN shell.bash hook)" conda activate myenv cd "$GAMEDIR" python rats.py