- Fonction utilitaire pour notifications système - Support différents niveaux: info, success, error, warning - Utilisé par md_to_print_gui.sh pour feedback utilisateur
47 lines
893 B
Bash
Executable File
47 lines
893 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script utilitaire pour les notifications MD_to_Print
|
|
# Usage: md_to_print_notify.sh [level] [message]
|
|
|
|
set -euo pipefail
|
|
|
|
LEVEL="${1:-info}"
|
|
MESSAGE="${2:-}"
|
|
ICON=""
|
|
URGENCY="normal"
|
|
|
|
case "$LEVEL" in
|
|
info|INFO)
|
|
ICON="dialog-information"
|
|
URGENCY="low"
|
|
;;
|
|
success|SUCCESS)
|
|
ICON="dialog-information"
|
|
URGENCY="normal"
|
|
;;
|
|
warning|WARN)
|
|
ICON="dialog-warning"
|
|
URGENCY="normal"
|
|
;;
|
|
error|ERROR)
|
|
ICON="dialog-error"
|
|
URGENCY="critical"
|
|
;;
|
|
*)
|
|
ICON="dialog-information"
|
|
URGENCY="normal"
|
|
;;
|
|
esac
|
|
|
|
if [ -z "$MESSAGE" ]; then
|
|
echo "Usage: $0 [level] [message]"
|
|
exit 1
|
|
fi
|
|
|
|
if command -v notify-send &> /dev/null; then
|
|
notify-send -u "$URGENCY" -i "$ICON" "MD_to_Print" "$MESSAGE" 2>/dev/null || true
|
|
else
|
|
echo "[$LEVEL] $MESSAGE" >&2
|
|
fi
|
|
|