From f8636c293addfb83eb7072dd75bc55591b733278 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 26 Dec 2016 00:24:43 -0500 Subject: [PATCH] +bin/pushover --- bin/pushover | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) mode change 100644 => 100755 bin/pushover diff --git a/bin/pushover b/bin/pushover old mode 100644 new mode 100755 index 6b0bd568..4474cef1 --- a/bin/pushover +++ b/bin/pushover @@ -1,3 +1,39 @@ #!/usr/bin/env bash -# TODO +if [[ ! -f "$HOME/.private/config/pushover.conf" ]]; then + >&2 echo "No pushover config file found (~/.private/config/pushover.conf)" + exit 1 +fi + +message= +title= +priority= +url= +device= + +while getopts t:m:p:u:d: opt; do + case $opt in + t) title="$OPTARG" ;; + m) message="$OPTARG" ;; + p) priority="$OPTARG" ;; + u) url="$OPTARG" ;; + U) url_title="$OPTARG" ;; + d) device="$OPTARG" ;; + *) >&2 echo "Invalid option $OPTARG" + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +. "$HOME/.private/config/pushover.conf" + +curl -s \ + --form-string "token=$TOKEN" \ + --form-string "user=$USER" \ + --form-string "title=$title" \ + --form-string "message=$message" \ + --form-string "url=$url" \ + --form-string "url_title=$url_title" \ + --form-string "device=$device" \ + https://api.pushover.net/1/messages.json