Skip to content
Permalink
Browse files

change to -m, move the parsing to the body, and document

  • Loading branch information...
hardaker authored and jnwatts committed May 14, 2017
1 parent 2bb6260 commit fa67864bf72bc2737cddfe816fa12104d2087f78
Showing with 15 additions and 10 deletions.
  1. +3 −0 README.md
  2. +12 −10 pushover.sh
@@ -31,10 +31,13 @@ Usage
-T <TOKEN> (required if not in config file)
-s <sound>
-u <url>
-m <msg_file>
-U <USER> (required if not in config file)

To use this script, you must have TOKEN and USER (or GROUP) keys from [PushOver][1]. These may then be specified on the terminal with `-T` and `-U`, or you may store default values for both in `${HOME}/.config/pushover.conf`. If you need to override this path, such as for multiple accounts, either specify the config file as a parameter using `-f` or use the environment variable PUSHOVER_CONFIG with the full path to the desired config file.

The message can be passed as arguments on the command line, or by using the -m switch to load the message from a file.

Config file format
==================

@@ -77,13 +77,6 @@ remove_duplicates() {
send_message() {
local device="${1:-}"

if [ "$msg_file" != "" ] ; then
if [ ! -f "$msg_file" ] ; then
echo "failed to read message file: $msg_file"
exit 1
fi
message="$message `cat $msg_file`"
fi
curl_cmd="\"${CURL}\" -s -S \
${CURL_OPTS} \
-F \"token=${TOKEN}\" \
@@ -117,7 +110,7 @@ devices="${devices} ${device}"

# Option parsing
# We allow options to override the config file, so we process and load it first
optstring="c:d:D:e:f:p:r:t:T:s:u:U:a:M:h"
optstring="c:d:D:e:f:p:r:t:T:s:u:U:a:m:h"
while getopts ${optstring} c; do
case ${c} in
f) PUSHOVER_CONFIG="${OPTARG}" ;;
@@ -147,7 +140,7 @@ while getopts ${optstring} c; do
t) title="${OPTARG}" ;;
T) TOKEN="${OPTARG}" ;;
s) sound="${OPTARG}" ;;
M) msg_file="${OPTARG}" ;;
m) msg_file="${OPTARG}" ;;
u) url="${OPTARG}" ;;
U) USER="${OPTARG}" ;;
a) url_title="${OPTARG}" ;;
@@ -158,11 +151,20 @@ done
shift $((OPTIND-1))

# Is there anything left?
if [ "$#" -lt 1 ]; then
if [ "$#" -lt 1 -a "$msg_file" = "" ]; then
usage
fi
message="$*"

# load the rest of the message from the file
if [ "$msg_file" != "" ] ; then
if [ ! -f "$msg_file" ] ; then
echo "failed to read message file: $msg_file"
exit 1
fi
message="$message `cat $msg_file`"
fi

# Check for required config variables
if [ ! -x "${CURL}" ]; then
echo "CURL is unset, empty, or does not point to curl executable. This script requires curl!" >&2

0 comments on commit fa67864

Please sign in to comment.
You can’t perform that action at this time.