Created
March 28, 2016 19:46
-
-
Save Habmala/339fd38bf2e032becc0d to your computer and use it in GitHub Desktop.
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 | |
#### pushoverNotifier ########################## | |
# Sends notifications through pushover. | |
# Pushover.net | pushover.net/api | |
################################################## | |
#### Some general settings ##################### | |
apiToken=**** | |
userKey=**** | |
returnFormat=xml | |
logfile="" | |
################################################## | |
#### Sounds #################################### | |
# Sound choises from the pushver API website | |
# (https://pushover.net/api#sounds) | |
# Set the notifications sound with -S | |
# | |
# pushover - Pushover (default) | |
# bike - Bike | |
# bugle - Bugle | |
# cashregister - Cash Register | |
# classical - Classical | |
# cosmic - Cosmic | |
# falling - Falling | |
# gamelan - Gamelan | |
# incoming - Incoming | |
# intermission - Intermission | |
# magic - Magic | |
# mechanical - Mechanical | |
# pianobar - Piano Bar | |
# siren - Siren | |
# spacealarm - Space Alarm | |
# tugboat - Tug Boat | |
# alien - Alien Alarm (long) | |
# climb - Climb (long) | |
# persistent - Persistent (long) | |
# echo - Pushover Echo (long) | |
# updown - Up Down (long) | |
# none - None (silent) | |
################################################## | |
#### Program executes ########################## | |
while [[ -n $1 ]]; do | |
case $1 in | |
-H | -h ) | |
header="$2" | |
shift | |
shift | |
;; | |
-M | -m ) | |
reminder="$2" | |
shift | |
shift | |
;; | |
-P | -p ) | |
priority="$2" | |
shift | |
shift | |
;; | |
-S | -s ) | |
sound="$2" | |
shift | |
shift | |
;; | |
-I | -i ) | |
echo "Title:" | |
read header | |
echo "Message:" | |
read reminder | |
echo "Priority:" | |
read priority | |
echo "Sound:" | |
read sound | |
break | |
;; | |
* ) | |
echo -e "Use -i for interactive och send message with flags\n-h for header, -m for message, -p for priority, -s for notification sound." | |
exit 1 | |
esac | |
done | |
curl -s \ | |
-F "token=${apiToken}" \ | |
-F "user=${userKey}" \ | |
-F "title=${header:-'From NotificationScript'}" \ | |
-F "priority=${priority:-0}" \ | |
-F "message=${reminder}" \ | |
-F "sound=${sound:-cosmic}" \ | |
https://api.pushover.net/1/messages.$returnFormat >> ${logfile:-/tmp/pushover.log} | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment