chiark / gitweb /
neovim: Update git commit used
[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 [-c content] [-i id] [-t title] [-u url]"
7     echo "Display a system notification."
8     echo ""
9     echo "  -c content notification content to show"
10     echo "  -i id      notification id (will overwrite any previous notification"
11     echo "               with the same id)"
12     echo "  -t title   notification title to show"
13     echo "  -u url     notification url when clicking on it"
14     echo ""
15     exit 0
16 }
17
18 CONTENT_OR_TITLE_SET=no
19 ARG_C=""
20 OPT_C=""
21 ARG_I=""
22 OPT_I=""
23 ARG_T=""
24 OPT_T=""
25 ARG_U=""
26 OPT_U=""
27
28 while getopts :hc:i:t:u: option
29 do
30         case "$option" in
31                 h) show_usage;;
32                 c) ARG_C="--es content"; OPT_C="$OPTARG"; CONTENT_OR_TITLE_SET=yes;;
33                 i) ARG_I="--es id"; OPT_I="$OPTARG";;
34                 t) ARG_T="--es title"; OPT_T="$OPTARG"; CONTENT_OR_TITLE_SET=yes;;
35                 u) ARG_U="--es url"; OPT_U="$OPTARG";;
36                 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
37         esac
38 done
39 shift $(($OPTIND-1))
40
41 if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
42
43 if [ $CONTENT_OR_TITLE_SET = "no" ]; then
44         echo "$SCRIPTNAME: no title or content set"
45         exit 1
46 fi
47
48 set --
49 if [ -n "$ARG_C" ]; then set -- "$@" $ARG_C "$OPT_C"; fi
50 if [ -n "$ARG_I" ]; then set -- "$@" $ARG_I "$OPT_I"; fi
51 if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
52 if [ -n "$ARG_U" ]; then set -- "$@" $ARG_U "$OPT_U"; fi
53
54 @TERMUX_API@ Notification "$@"