#!/usr/bin/env bash
# Python compile sanity + systemd unit linkage (no running daemon required).
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OVERDECK_ROOT="$(cd "$ROOT/../.." && pwd)"
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}"
SYSTEMD_USER_DIR="${XDG_CONFIG_HOME}/systemd/user"

fail() {
  echo "health: $1" >&2
  exit 1
}

if ! python3 -m compileall -q "$OVERDECK_ROOT/modules/systray"; then
  fail "python compileall failed for modules/systray"
fi

if [[ ! -e "$SYSTEMD_USER_DIR/systray-ai.service" ]]; then
  fail "systemd unit not linked: $SYSTEMD_USER_DIR/systray-ai.service"
fi

exit 0
