notification: do not allow empty id with --ongoing

Ongoing notifications can only be removed with
termux-notification-remove, which requires the notification id.
An ongoing notification without an id requires a reboot to be removed.
This commit forbids creating such an "unremovable" notification.
This commit is contained in:
Alessandro Caputo 2019-08-08 01:18:44 +02:00
parent 0b1845fe5d
commit 3f68215d12

6
scripts/termux-notification Normal file → Executable file
View File

@ -114,6 +114,12 @@ done
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
if [ "$OPT_ONGOING" == true ] && [ -z "$OPT_ID" ]; then
echo "Ongoing notifications without an ID are not removable."
echo "Please set an id with --id \"string\"."
exit 1
fi
set --
if [ -n "$OPT_ACTION" ]; then set -- "$@" --es action "$OPT_ACTION"; fi
if [ -n "$OPT_ALERT_ONCE" ]; then set -- "$@" --ez alert-once "$OPT_ALERT_ONCE"; fi