Skip to content

Instantly share code, notes, and snippets.

@ifitzpat
Forked from joech4n/boxcar-growl.py
Last active January 8, 2016 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifitzpat/99689b7b64d6d560d94d to your computer and use it in GitHub Desktop.
Save ifitzpat/99689b7b64d6d560d94d to your computer and use it in GitHub Desktop.
boxcar-growl.py - Send Boxcar Notification with CLI (Python)
#!/usr/bin/env python
import os
import sys
import subprocess
import shlex
def notify (token, mymessage, mytitle):
# Default config
DEFAULT_SOUND = 'clanging'
DEFAULT_IMAGE = 'http://i.imgur.com/Fea7vsF.png'
# Example: curl -d "user_credentials=ACCESS_TOKEN" -d "notification[title]=message title" -d "notification[long_message]=<b>Some text or HTML for the full layout page notification</b>" -d "notification[sound]=bird-1" -d "notification[source_name]=My own alert" -d "notification[icon_url]=http://new.boxcar.io/images/rss_icons/boxcar-64.png" https://new.boxcar.io/api/notifications
curlCmd = []
curlCmd.append('curl')
curlCmd.append('-d "user_credentials=' + token + '"')
curlCmd.append('-d "notification[title]=' + mytitle + '"')
curlCmd.append('-d "notification[long_message]=' + mymessage + '"')
curlCmd.append('-d "notification[sound]=' + DEFAULT_SOUND + '"')
curlCmd.append('-d "notification[icon_url]=' + DEFAULT_IMAGE + '"')
curlCmd.append('https://new.boxcar.io/api/notifications')
subprocess.call(shlex.split(' '.join(curlCmd)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment