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

LABEL="${SOFIIA_LAUNCHD_LABEL:-com.daarion.sofiia}"
DOMAIN="gui/$(id -u)"
PLIST_PATH="${HOME}/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "${DOMAIN}/${LABEL}" >/dev/null 2>&1 || true
launchctl disable "${DOMAIN}/${LABEL}" >/dev/null 2>&1 || true

if [ -f "${PLIST_PATH}" ]; then
  rm -f "${PLIST_PATH}"
fi

echo "[sofiia-launchd] removed: ${PLIST_PATH}"
