Skip to content

Instantly share code, notes, and snippets.

@jjrdn
Forked from rnorth/bc
Created April 20, 2014 22:34
Show Gist options
  • Save jjrdn/11126954 to your computer and use it in GitHub Desktop.
Save jjrdn/11126954 to your computer and use it in GitHub Desktop.
#!/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