39 lines
1.1 KiB
Plaintext
39 lines
1.1 KiB
Plaintext
|
#!/system/bin/sh
|
||
|
|
||
|
set -u
|
||
|
|
||
|
PARAMS=""
|
||
|
CONTENT_OR_TITLE_SET=no
|
||
|
|
||
|
SCRIPTNAME=$0
|
||
|
show_usage () {
|
||
|
echo "usage: termux-notification [OPTIONS]"
|
||
|
echo "Display a notification. Options:"
|
||
|
echo " -c, --content <content> notification content to show"
|
||
|
echo " -i, --id <id> notification id (will overwrite the previous notification with the same id)"
|
||
|
echo " -t, --title <title> notification title to show"
|
||
|
echo " -u, --url <url> notification url when clicking on it"
|
||
|
}
|
||
|
|
||
|
O=`busybox getopt -q -l content: -l help -l title: -l id: -l url: -- c:hi:t:u: "$@"`
|
||
|
if [ $? != 0 ] ; then show_usage; exit 1 ; fi
|
||
|
eval set -- "$O"
|
||
|
while true; do
|
||
|
case "$1" in
|
||
|
-c|--content) PARAMS="$PARAMS --es content $2"; CONTENT_OR_TITLE_SET=yes; shift 2;;
|
||
|
-h|--help) show_usage; exit 0;;
|
||
|
-i|--id) PARAMS="$PARAMS --es id $2"; shift 2;;
|
||
|
-t|--title) PARAMS="$PARAMS --es title $2"; CONTENT_OR_TITLE_SET=yes; shift 2;;
|
||
|
-u|--url) PARAMS="$PARAMS --es url $2"; shift 2;;
|
||
|
--) shift; break;;
|
||
|
*) echo Error; exit 1;;
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
if [ $CONTENT_OR_TITLE_SET = "no" ]; then
|
||
|
show_usage
|
||
|
exit 1;
|
||
|
fi;
|
||
|
|
||
|
termux-api Notification $PARAMS
|