Monorepo for Aesthetic.Computer aesthetic.computer
at main 28 lines 1.0 kB view raw
1#!/bin/bash 2 3# ac-notify - Send notifications to ac-event-daemon 4# Usage: ac-notify [success|error|info] [message] 5# Set VERBOSE=1 for debug output 6 7NOTIFICATION_TYPE="${1:-success}" 8MESSAGE="${2:-Prompt completed}" 9 10# Determine host address (container vs native) 11if [ -n "$CODESPACES" ] || [ -n "$DEVCONTAINER" ] || [ -f /.dockerenv ]; then 12 # In a container - get the default gateway IP 13 GATEWAY_IP=$(ip route show default | awk '/default/ {print $3}' | head -1) 14 HOST_ADDR="${GATEWAY_IP:-172.17.0.1}" 15 # Only show debug info if verbose mode is requested 16 [ "${VERBOSE:-}" = "1" ] && echo "Container detected, using host address: $HOST_ADDR" >&2 17else 18 HOST_ADDR="127.0.0.1" 19fi 20 21# Send UDP message to ac-event-daemon 22echo "prompt-complete:${NOTIFICATION_TYPE}:${MESSAGE}" | nc -u "$HOST_ADDR" 9999 2>/dev/null || { 23 # If nc fails, try sending directly via filesystem (fallback) 24 echo "Warning: Could not send notification to ac-event-daemon" >&2 25 exit 1 26} 27 28echo "Notification sent: ${NOTIFICATION_TYPE} - ${MESSAGE}"