commit 545dddedbe343c0a861be0d25c26536c9a76f64a parent be75e98776e029392717ba957539063eac02eee7 Author: Claudio Alessi <smoppy@gmail.com> Date: Fri, 19 Aug 2022 17:41:59 +0200 Add the sendpush script. Diffstat:
M | README.md | | | 12 | ++++++++++++ |
A | src/sendpush | | | 32 | ++++++++++++++++++++++++++++++++ |
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md @@ -22,6 +22,7 @@ index * [setmon](#setmon) - Switch to HDMI video/audio if any. * [moin](#moin) - Play a random song from a YouTube playlist. * [fetchpic](#fetchpic) - Fetch a random pic from a random blog (of a given list). +* [sendpush](#sendpush) - Send a PUSH notification via xdroid API txthole ------- @@ -378,3 +379,14 @@ done & ``` Enjoy. + +sendpush +-------- +Send a PUSH notification to your smartphone via xdroid API. + +``` +$ sendpush -h +sendpush -k <key> -t <title> -c <conten> [-u <uri>] +``` + +Install the [app](https://play.google.com/store/apps/details?id=net.xdroid.pn) and you're done. diff --git a/src/sendpush b/src/sendpush @@ -0,0 +1,32 @@ +#!/bin/sh +# Send PUSH notifications via xdroid API +# https://play.google.com/store/apps/details?id=net.xdroid.pn + +usage() { + echo "Usage: $0 -k <key> -t <title> -c <conten> [-u <uri>]" + exit 1 +} + +main() { + while getopts "k:t:c:u:h" o; do + case $o in + k) apikey="$OPTARG";; + t) title="$OPTARG";; + c) content="$OPTARG";; + u) uri="$OPTARG";; + h) usage;; + esac + shift "$(echo "$OPTIND - 1"|bc)" + done + + [ -z "$apikey" -o -z "$title" -o -z "$content" ] && usage + + curl --get \ + --data-urlencode "k=$apikey" \ + --data-urlencode "t=$title" \ + --data-urlencode "c=$content" \ + --data-urlencode "u=$uri" \ + "https://xdroid.net/api/message" +} + +main "$@"