chiark / gitweb /
96a0e2a53e0902fa9f0879fbfea032b6777bc538
[termux-packages] / packages / termux-api / termux-notification
1 #!/bin/sh
2 set -e -u
3
4 SCRIPTNAME=termux-notification
5 show_usage () {
6         echo "usage: termux-notification [OPTIONS]"
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
14 }
15
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
36 done
37 shift $(($OPTIND-1))
38
39 if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
40
41 if [ $CONTENT_OR_TITLE_SET = "no" ]; then
42         echo "$SCRIPTNAME: no title or content set"
43         exit 1
44 fi
45
46 @TERMUX_API@ Notification $ARG_C "$OPT_C" $ARG_I "$OPT_I" $ARG_T "$OPT_T" $ARG_U "$OPT_U"