87 lines
3.5 KiB
Bash
Executable file
87 lines
3.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# ==============================================================================
|
|
# Script de Notificação do Sistema Operacional (Compatível com Linux & macOS)
|
|
# Uso: sh .agent/notificar.sh "<Título>" "<Mensagem>" [sucesso|aviso|erro]
|
|
# ==============================================================================
|
|
|
|
TITULO="${1:-Antigravity /goal}"
|
|
MENSAGEM="${2:-Trabalho concluído com sucesso!}"
|
|
TIPO="${3:-sucesso}"
|
|
|
|
# 1. Sinal sonoro universal do terminal (CLI)
|
|
printf '\a' 2>/dev/null || true
|
|
|
|
OS_NAME="$(uname -s 2>/dev/null || echo "Desconhecido")"
|
|
|
|
# 2. Execução assíncrona por Sistema Operacional (não bloqueia o terminal)
|
|
(
|
|
case "$OS_NAME" in
|
|
Darwin*)
|
|
# --- macOS ---
|
|
# Som nativo do macOS
|
|
case "$TIPO" in
|
|
erro) SOM_MAC="/System/Library/Sounds/Basso.aiff" ;;
|
|
aviso) SOM_MAC="/System/Library/Sounds/Sosumi.aiff" ;;
|
|
*) SOM_MAC="/System/Library/Sounds/Glass.aiff" ;;
|
|
esac
|
|
[ -f "$SOM_MAC" ] && afplay "$SOM_MAC" >/dev/null 2>&1 &
|
|
|
|
# Notificação Desktop via AppleScript
|
|
if command -v osascript >/dev/null 2>&1; then
|
|
osascript -e "display notification \"$MENSAGEM\" with title \"$TITULO\" subtitle \"Antigravity\"" >/dev/null 2>&1
|
|
elif command -v terminal-notifier >/dev/null 2>&1; then
|
|
terminal-notifier -title "$TITULO" -message "$MENSAGEM" >/dev/null 2>&1
|
|
fi
|
|
;;
|
|
|
|
Linux*)
|
|
# --- Linux ---
|
|
# Som nativo via PipeWire, PulseAudio ou Canberra
|
|
case "$TIPO" in
|
|
erro)
|
|
SOM_LINUX="/usr/share/sounds/freedesktop/stereo/dialog-error.oga"
|
|
[ ! -f "$SOM_LINUX" ] && SOM_LINUX="/usr/share/sounds/Oxygen-Sys-App-Error.ogg"
|
|
;;
|
|
aviso)
|
|
SOM_LINUX="/usr/share/sounds/freedesktop/stereo/dialog-warning.oga"
|
|
[ ! -f "$SOM_LINUX" ] && SOM_LINUX="/usr/share/sounds/Oxygen-Sys-Warning.ogg"
|
|
;;
|
|
*)
|
|
SOM_LINUX="/usr/share/sounds/Oxygen-Sys-App-Positive.ogg"
|
|
[ ! -f "$SOM_LINUX" ] && SOM_LINUX="/usr/share/sounds/freedesktop/stereo/complete.oga"
|
|
[ ! -f "$SOM_LINUX" ] && SOM_LINUX="/usr/share/sounds/ocean/stereo/dialog-information.oga"
|
|
;;
|
|
esac
|
|
|
|
if [ -f "$SOM_LINUX" ]; then
|
|
if command -v pw-play >/dev/null 2>&1; then
|
|
pw-play "$SOM_LINUX" >/dev/null 2>&1 &
|
|
elif command -v paplay >/dev/null 2>&1; then
|
|
paplay "$SOM_LINUX" >/dev/null 2>&1 &
|
|
elif command -v aplay >/dev/null 2>&1; then
|
|
aplay "$SOM_LINUX" >/dev/null 2>&1 &
|
|
fi
|
|
elif command -v canberra-gtk-play >/dev/null 2>&1; then
|
|
canberra-gtk-play -i complete >/dev/null 2>&1 &
|
|
fi
|
|
|
|
# Notificação Desktop (KDE / GNOME / XFCE / DBus)
|
|
if [ -n "$DISPLAY$WAYLAND_DISPLAY" ]; then
|
|
if command -v kdialog >/dev/null 2>&1; then
|
|
kdialog --title "$TITULO" --passivepopup "$MENSAGEM" 5 >/dev/null 2>&1
|
|
elif command -v notify-send >/dev/null 2>&1; then
|
|
notify-send -u normal -a "Antigravity" "$TITULO" "$MENSAGEM" >/dev/null 2>&1
|
|
elif command -v gdbus >/dev/null 2>&1; then
|
|
gdbus call --session --dest org.freedesktop.Notifications \
|
|
--object-path /org/freedesktop/Notifications \
|
|
--method org.freedesktop.Notifications.Notify \
|
|
"Antigravity" 0 "" "$TITULO" "$MENSAGEM" "[]" "{}" 5000 >/dev/null 2>&1
|
|
elif command -v zenity >/dev/null 2>&1; then
|
|
zenity --notification --text="$TITULO: $MENSAGEM" >/dev/null 2>&1
|
|
fi
|
|
fi
|
|
;;
|
|
esac
|
|
) >/dev/null 2>&1 &
|
|
|
|
exit 0
|