#!/usr/bin/env bash
FLAG="$HOME/.factory-welcome-done"

if [[ -f "$FLAG" ]]; then
    exit 0
fi

/opt/factoryos-welcome/FactoryOS-Welcome.AppImage --no-sandbox "$@" &

# Wait for the app to close, then mark as done
while pgrep -f "FactoryOS-Welcome.AppImage" > /dev/null 2>&1; do
    sleep 2
done

touch "$FLAG"
