Commit | Line | Data |
---|---|---|
59f0d218 FF |
1 | #!/system/bin/sh |
2 | ||
3 | set -u | |
4 | ||
5 | PARAMS="" | |
6 | CONTENT_OR_TITLE_SET=no | |
7 | ||
8 | SCRIPTNAME=$0 | |
9 | show_usage () { | |
10 | echo "usage: termux-notification [OPTIONS]" | |
11 | echo "Display a notification. Options:" | |
12 | echo " -c, --content <content> notification content to show" | |
13 | echo " -i, --id <id> notification id (will overwrite the previous notification with the same id)" | |
14 | echo " -t, --title <title> notification title to show" | |
15 | echo " -u, --url <url> notification url when clicking on it" | |
16 | } | |
17 | ||
18 | O=`busybox getopt -q -l content: -l help -l title: -l id: -l url: -- c:hi:t:u: "$@"` | |
19 | if [ $? != 0 ] ; then show_usage; exit 1 ; fi | |
20 | eval set -- "$O" | |
21 | while true; do | |
22 | case "$1" in | |
23 | -c|--content) PARAMS="$PARAMS --es content $2"; CONTENT_OR_TITLE_SET=yes; shift 2;; | |
24 | -h|--help) show_usage; exit 0;; | |
25 | -i|--id) PARAMS="$PARAMS --es id $2"; shift 2;; | |
26 | -t|--title) PARAMS="$PARAMS --es title $2"; CONTENT_OR_TITLE_SET=yes; shift 2;; | |
27 | -u|--url) PARAMS="$PARAMS --es url $2"; shift 2;; | |
28 | --) shift; break;; | |
29 | *) echo Error; exit 1;; | |
30 | esac | |
31 | done | |
32 | ||
33 | if [ $CONTENT_OR_TITLE_SET = "no" ]; then | |
34 | show_usage | |
35 | exit 1; | |
36 | fi; | |
37 | ||
38 | termux-api Notification $PARAMS |