Commit | Line | Data |
---|---|---|
cc1ae02e | 1 | #!/bin/sh |
0ec2b704 | 2 | set -e -u |
59f0d218 | 3 | |
0ec2b704 | 4 | SCRIPTNAME=termux-notification |
59f0d218 FF |
5 | show_usage () { |
6 | echo "usage: termux-notification [OPTIONS]" | |
0ec2b704 FF |
7 | echo "Display a system notification." |
8 | echo "" | |
9 | echo " -c <content> notification content to show" | |
10 | echo " -i <id> notification id (will overwrite the previous notification with the same id)" | |
11 | echo " -t <title> notification title to show" | |
12 | echo " -u <url> notification url when clicking on it" | |
13 | exit 1 | |
59f0d218 FF |
14 | } |
15 | ||
0ec2b704 FF |
16 | CONTENT_OR_TITLE_SET=no |
17 | ARG_C="" | |
18 | OPT_C="" | |
19 | ARG_I="" | |
20 | OPT_I="" | |
21 | ARG_T="" | |
22 | OPT_T="" | |
23 | ARG_U="" | |
24 | OPT_U="" | |
25 | ||
26 | while getopts :hc:i:t:u: option | |
27 | do | |
28 | case "$option" in | |
29 | h) show_usage;; | |
30 | c) ARG_C="--es content"; OPT_C="$OPTARG"; CONTENT_OR_TITLE_SET=yes;; | |
31 | i) ARG_I="--es id"; OPT_I="$OPTARG";; | |
32 | t) ARG_T="--es title"; OPT_T="$OPTARG"; CONTENT_OR_TITLE_SET=yes;; | |
33 | u) ARG_U="--es url"; OPT_U="$OPTARG";; | |
34 | ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; | |
35 | esac | |
59f0d218 | 36 | done |
0ec2b704 FF |
37 | shift $(($OPTIND-1)) |
38 | ||
39 | if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi | |
59f0d218 FF |
40 | |
41 | if [ $CONTENT_OR_TITLE_SET = "no" ]; then | |
0ec2b704 FF |
42 | echo "$SCRIPTNAME: no title or content set" |
43 | exit 1 | |
44 | fi | |
59f0d218 | 45 | |
0ec2b704 | 46 | @TERMUX_API@ Notification $ARG_C "$OPT_C" $ARG_I "$OPT_I" $ARG_T "$OPT_T" $ARG_U "$OPT_U" |