2015-08-14 21:27:47 +02:00
|
|
|
#!/bin/sh
|
2016-04-19 16:34:01 +02:00
|
|
|
set -e -u
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2016-04-19 16:34:01 +02:00
|
|
|
SCRIPTNAME=termux-notification
|
2015-06-13 01:03:31 +02:00
|
|
|
show_usage () {
|
|
|
|
echo "usage: termux-notification [OPTIONS]"
|
2016-04-19 16:34:01 +02:00
|
|
|
echo "Display a system notification."
|
|
|
|
echo ""
|
|
|
|
echo " -c <content> notification content to show"
|
|
|
|
echo " -i <id> notification id (will overwrite the previous notification with the same id)"
|
|
|
|
echo " -t <title> notification title to show"
|
|
|
|
echo " -u <url> notification url when clicking on it"
|
|
|
|
exit 1
|
2015-06-13 01:03:31 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 16:34:01 +02:00
|
|
|
CONTENT_OR_TITLE_SET=no
|
|
|
|
ARG_C=""
|
|
|
|
OPT_C=""
|
|
|
|
ARG_I=""
|
|
|
|
OPT_I=""
|
|
|
|
ARG_T=""
|
|
|
|
OPT_T=""
|
|
|
|
ARG_U=""
|
|
|
|
OPT_U=""
|
|
|
|
|
|
|
|
while getopts :hc:i:t:u: option
|
|
|
|
do
|
|
|
|
case "$option" in
|
|
|
|
h) show_usage;;
|
|
|
|
c) ARG_C="--es content"; OPT_C="$OPTARG"; CONTENT_OR_TITLE_SET=yes;;
|
|
|
|
i) ARG_I="--es id"; OPT_I="$OPTARG";;
|
|
|
|
t) ARG_T="--es title"; OPT_T="$OPTARG"; CONTENT_OR_TITLE_SET=yes;;
|
|
|
|
u) ARG_U="--es url"; OPT_U="$OPTARG";;
|
|
|
|
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
|
|
|
|
esac
|
2015-06-13 01:03:31 +02:00
|
|
|
done
|
2016-04-19 16:34:01 +02:00
|
|
|
shift $(($OPTIND-1))
|
|
|
|
|
|
|
|
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
|
2015-06-13 01:03:31 +02:00
|
|
|
|
|
|
|
if [ $CONTENT_OR_TITLE_SET = "no" ]; then
|
2016-04-19 16:34:01 +02:00
|
|
|
echo "$SCRIPTNAME: no title or content set"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2016-04-19 16:34:01 +02:00
|
|
|
@TERMUX_API@ Notification $ARG_C "$OPT_C" $ARG_I "$OPT_I" $ARG_T "$OPT_T" $ARG_U "$OPT_U"
|