-
-
Save rnorth/11121360 to your computer and use it in GitHub Desktop.
Boxcar push notification shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Sends a Boxcar push notification through the Boxcar HTTP API | |
# Usage examples | |
# $ bc # Just sends a notification with title 'bc' | |
# $ bc "Done" # Sends a notification with title 'Done' | |
# $ echo foobar | bc # Sends a notification with title 'bc' and message body 'foobar' | |
# $ echo foobar | bc "Done" # Sends a notification with title 'Done' and message body 'foobar' | |
# | |
# Expects a file ~/.boxcar to exist with content like | |
# BOXCAR_ACCESS_TOKEN=<your boxcar access token goes here> | |
. ~/.boxcar | |
TITLE=${1:-bc} | |
BOXCAR_SOUND=${BOXCAR_SOUND:-score} | |
# Only read a message if NOT a tty, e.g. if stdin is piped in | |
tty -s | |
if [[ ! $? == 0 ]]; then | |
read MESSAGE | |
fi | |
curl -d "user_credentials=${BOXCAR_ACCESS_TOKEN}" \ | |
-d "notification[title]=${TITLE}" \ | |
-d "notification[long_message]=${MESSAGE}" \ | |
-d "notification[sound]=${BOXCAR_SOUND}" \ | |
https://new.boxcar.io/api/notifications |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment