diff --git a/scripts/ntfy-me b/scripts/ntfy-cmd similarity index 88% rename from scripts/ntfy-me rename to scripts/ntfy-cmd index 7d53221..c6b7bd8 100755 --- a/scripts/ntfy-me +++ b/scripts/ntfy-cmd @@ -1,14 +1,14 @@ #!/usr/bin/env bash # -# ntfy-me — run any command, then send ntfy success/failure notification (via curl) +# ntfy-cmd — run any command, then send ntfy success/failure notification (via curl) # # Usage: -# ntfy-me [args...] +# ntfy-cmd [args...] # # Example: -# ntfy-me make build -# ntfy-me bash -c "sleep 10 && false" -# ntfy-me ls /nonexistent +# ntfy-cmd make build +# ntfy-cmd bash -c "sleep 10 && false" +# ntfy-cmd ls /nonexistent # # Notes: # - Requires $NTFY_ME_TOPIC set (e.g., mytopic) @@ -76,3 +76,4 @@ curl -fsS -X POST \ "$NTFY_HOST/$NTFY_ME_TOPIC" >/dev/null 2>&1 || echo "Warning: failed to send ntfy notification" >&2 exit $code + diff --git a/scripts/ntfy-msg b/scripts/ntfy-msg new file mode 100755 index 0000000..ea096c7 --- /dev/null +++ b/scripts/ntfy-msg @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# ntfy-msg — send a message to ntfy (via curl) +# +# Usage: +# ntfy-msg +# +# Example: +# ntfy-msg "Build finished" +# +# Notes: +# - Requires $NTFY_ME_TOPIC set (e.g., mytopic) +# - Optional $NTFY_HOST (defaults to https://ntfy.sh) + +set -u + +if [ -z "${NTFY_ME_TOPIC:-}" ]; then + echo "Error: NTFY_ME_TOPIC environment variable not set." + echo "Set it like: export NTFY_ME_TOPIC=mytopic" + exit 1 +fi + +# Set default ntfy host if not provided +NTFY_HOST="${NTFY_HOST:-https://ntfy.sh}" + +if [ $# -lt 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +message="$*" + +curl -fsS -X POST \ + -d "$message" \ + "$NTFY_HOST/$NTFY_ME_TOPIC" >/dev/null 2>&1 || echo "Warning: failed to send ntfy message" >&2 +