Ashlar checks / tooling (push) Successful in 5s
Set MORROWIND_DATA to a Data Files folder to play it, mounted read-only, with its own settings and saves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
3.1 KiB
Bash
Executable File
78 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Plays the built engine in a window on this desktop, using the NVIDIA GPU and
|
|
# PulseAudio. By default it loads the asset-free Game Template. Set
|
|
# MORROWIND_DATA to your own Morrowind "Data Files" folder to load that instead.
|
|
# Extra arguments go to openmw, for example --skip-menu --new-game.
|
|
# Run docker/ashlar-build.sh first.
|
|
set -euo pipefail
|
|
|
|
repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cache="${ASHLAR_CACHE_DIR:-$HOME/.cache/ashlar}"
|
|
image="ashlar-build:trixie"
|
|
suite="$cache/content/example-suite"
|
|
pulse="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/pulse/native"
|
|
morrowind="${MORROWIND_DATA:-}"
|
|
|
|
[ -x "$cache/build/openmw" ] || { echo "Run docker/ashlar-build.sh first." >&2; exit 1; }
|
|
[ -n "${DISPLAY:-}" ] || { echo "DISPLAY is not set." >&2; exit 1; }
|
|
|
|
docker build -q -t "$image" -f "$repo/docker/Dockerfile.ashlar" "$repo/docker" >/dev/null
|
|
|
|
if [ -n "$morrowind" ]; then
|
|
# Each profile keeps its own settings and saves.
|
|
play="$cache/play-morrowind"
|
|
mkdir -p "$play/home/.config/openmw"
|
|
find_file() { find "$morrowind" -maxdepth 1 -iname "$1" -printf '%f\n' | head -1; }
|
|
[ -n "$(find_file Morrowind.esm)" ] || { echo "No Morrowind.esm in $morrowind" >&2; exit 1; }
|
|
{
|
|
echo 'data="/morrowind"'
|
|
for name in Morrowind Tribunal Bloodmoon; do
|
|
bsa="$(find_file "$name.bsa")"; if [ -n "$bsa" ]; then echo "fallback-archive=$bsa"; fi
|
|
done
|
|
for name in Morrowind Tribunal Bloodmoon; do
|
|
esm="$(find_file "$name.esm")"; if [ -n "$esm" ]; then echo "content=$esm"; fi
|
|
done
|
|
} > "$play/home/.config/openmw/openmw.cfg"
|
|
if [ ! -f "$play/home/.config/openmw/settings.cfg" ]; then
|
|
printf '[Video]\nresolution x = 1600\nresolution y = 900\nwindow mode = 2\n' \
|
|
> "$play/home/.config/openmw/settings.cfg"
|
|
fi
|
|
else
|
|
play="$cache/play"
|
|
[ -d "$suite" ] || git clone --depth 1 https://gitlab.com/OpenMW/example-suite.git "$suite"
|
|
mkdir -p "$play/home/.config/openmw"
|
|
cat > "$play/home/.config/openmw/openmw.cfg" <<'EOF'
|
|
data="/cache/content/example-suite/game_template/data"
|
|
content=template.omwgame
|
|
EOF
|
|
if [ ! -f "$play/home/.config/openmw/settings.cfg" ]; then
|
|
{
|
|
cat "$suite/settings.cfg"
|
|
printf '\n[Video]\nresolution x = 1600\nresolution y = 900\nwindow mode = 2\n'
|
|
} > "$play/home/.config/openmw/settings.cfg"
|
|
fi
|
|
fi
|
|
|
|
args=(
|
|
--rm
|
|
--user "$(id -u):$(id -g)"
|
|
--device nvidia.com/gpu=all
|
|
--env NVIDIA_DRIVER_CAPABILITIES=all
|
|
--env HOME="/cache/${play#"$cache"/}/home"
|
|
--env DISPLAY="$DISPLAY"
|
|
--volume /tmp/.X11-unix:/tmp/.X11-unix:ro
|
|
--volume "$cache:/cache"
|
|
--workdir /cache/build
|
|
)
|
|
if [ -n "${XAUTHORITY:-}" ] && [ -f "$XAUTHORITY" ]; then
|
|
args+=(--volume "$XAUTHORITY:/tmp/.Xauthority:ro" --env XAUTHORITY=/tmp/.Xauthority)
|
|
fi
|
|
if [ -n "$morrowind" ]; then
|
|
args+=(--volume "$morrowind:/morrowind:ro")
|
|
fi
|
|
if [ -S "$pulse" ]; then
|
|
args+=(--volume "$pulse:/tmp/pulse.sock" --env PULSE_SERVER=unix:/tmp/pulse.sock)
|
|
fi
|
|
|
|
docker run "${args[@]}" "$image" ./openmw "$@" 2>&1 | tee "$play/stdout.log"
|