#!/bin/bash
# Run Blender in headless mode with virtual display

# Start Xvfb in background
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
XVFB_PID=$!

# Wait for Xvfb to start
sleep 2

# Run Blender with all arguments passed to this script
blender "$@"
BLENDER_EXIT=$?

# Cleanup Xvfb
kill $XVFB_PID 2>/dev/null || true

exit $BLENDER_EXIT