#!/usr/bin/env bash
set -euo pipefail

LABEL="${AURORA_LAUNCHD_LABEL:-com.daarion.aurora}"
DOMAIN="gui/$(id -u)"
DATA_DIR_VALUE="${AURORA_DATA_DIR:-${HOME}/.sofiia/aurora-data}"
LOG_OUT="${DATA_DIR_VALUE}/logs/launchd.out.log"
LOG_ERR="${DATA_DIR_VALUE}/logs/launchd.err.log"

echo "[aurora-launchd] domain: ${DOMAIN}"
echo "[aurora-launchd] label: ${LABEL}"
echo ""
launchctl print "${DOMAIN}/${LABEL}" || true
echo ""
echo "[aurora-launchd] tail stdout (${LOG_OUT})"
tail -n 40 "${LOG_OUT}" 2>/dev/null || true
echo ""
echo "[aurora-launchd] tail stderr (${LOG_ERR})"
tail -n 80 "${LOG_ERR}" 2>/dev/null || true
