#!/bin/sh
# aero-lofi — loops the subtle AeroOS lofi track on the PipeWire graph.
# Kept intentionally simple: loop a seamless WAV with pw-play (falls back to
# paplay / aplay). Volume is held low for a "subtle" background feel.

TRACK="${AERO_LOFI_TRACK:-/usr/share/aeros/lofi/aero-lofi.wav}"
VOL="${AERO_LOFI_VOLUME:-0.35}"

[ -r "$TRACK" ] || { echo "aero-lofi: no track at $TRACK" >&2; exit 1; }

player() {
    if command -v pw-play >/dev/null 2>&1; then
        pw-play --volume "$VOL" "$TRACK"
    elif command -v paplay >/dev/null 2>&1; then
        paplay "$TRACK"
    elif command -v aplay >/dev/null 2>&1; then
        aplay -q "$TRACK"
    else
        echo "aero-lofi: no audio player available" >&2
        sleep 3600
    fi
}

# Loop forever (the track itself is a seamless loop).
while :; do
    player || sleep 2
done
