php: Update from 7.1.1 to 7.1.2 and enable pcntl
[termux-packages] / packages / termux-api / termux-notification
1 #!/data/data/com.termux/files/usr/bin/bash
2 set -e -u
3
4 SCRIPTNAME=termux-notification
5 show_usage () {
6 echo "Usage: termux-notification [options]"
7 echo "Display a system notification. Context text is read from stdin or specified using --content."
8 echo " --action action action to execute when pressing the notification"
9 echo " --button1 text text to show on the first notification button"
10 echo " --button1-action action action to execute on the first notification button"
11 echo " --button2 text text to show on the second notification button"
12 echo " --button2-action action action to execute on the second notification button"
13 echo " --button3 text text to show on the third notification button"
14 echo " --button3-action action action to execute on the third notification button"
15 echo " --content content contnet to show in the notification. Read from stdin not specified here."
16 echo " --id id notification id (will overwrite any previous notification with the same id)"
17 echo " --led-color rrggbb color of the blinking led as RRGGBB (default: none)"
18 echo " --led-on milliseconds number of milliseconds for the LED to be on while it's flashing (default: 800)"
19 echo " --led-off milliseconds number of milliseconds for the LED to be off while it's flashing (default: 800)"
20 echo " --priority prio notification priority (high/low/max/min/default)"
21 echo " --sound play a sound with the notification"
22 echo " --title title notification title to show"
23 echo " --vibrate pattern vibrate pattern, comma separated as in 500,1000,200"
24 exit 0
25 }
26
27 OPT_ACTION=""
28 OPT_ID=""
29 OPT_LED_COLOR=""
30 OPT_LED_OFF=""
31 OPT_LED_ON=""
32 OPT_PRIORITY=""
33 OPT_SOUND=""
34 OPT_TITLE=""
35 OPT_VIBRATE=""
36 OPT_BUTTON1_TEXT=""
37 OPT_BUTTON1_ACTION=""
38 OPT_BUTTON2_TEXT=""
39 OPT_BUTTON2_ACTION=""
40 OPT_BUTTON3_TEXT=""
41 OPT_BUTTON3_ACTION=""
42
43 TEMP=`busybox getopt \
44 -n $SCRIPTNAME \
45 -o hc:i:t: \
46 --long action:,\
47 button1:,button1-action:,\
48 button2:,button2-action:,\
49 button3:,button3-action:,\
50 content:,help,id:,\
51 led-color:,led-on:,led-off:,\
52 priority:,sound,title:,vibrate: \
53 -s bash \
54 -- "$@"`
55 eval set -- "$TEMP"
56
57 while true; do
58 case "$1" in
59 --action) OPT_ACTION="$2"; shift 2;;
60 --button1) OPT_BUTTON1_TEXT="$2"; shift 2;;
61 --button1-action) OPT_BUTTON1_ACTION="$2"; shift 2;;
62 --button2) OPT_BUTTON2_TEXT="$2"; shift 2;;
63 --button2-action) OPT_BUTTON2_ACTION="$2"; shift 2;;
64 --button3) OPT_BUTTON3_TEXT="$2"; shift 2;;
65 --button3-action) OPT_BUTTON3_ACTION="$2"; shift 2;;
66 -c | --content) OPT_CONTENT="$2"; shift 2;;
67 -h | --help) show_usage;;
68 -i | --id) OPT_ID="$2"; shift 2;;
69 --led-color) OPT_LED_COLOR="$2"; shift 2;;
70 --led-on) OPT_LED_ON="$2"; shift 2;;
71 --led-off) OPT_LED_OFF="$2"; shift 2;;
72 --priority) OPT_PRIORITY="$2"; shift 2;;
73 --sound) OPT_SOUND="true"; shift 1;;
74 -t | --title) OPT_TITLE="$2"; shift 2;;
75 --vibrate) OPT_VIBRATE="$2"; shift 2;;
76 --) shift; break ;;
77 esac
78 done
79
80 if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
81
82 set --
83 if [ -n "$OPT_ACTION" ]; then set -- "$@" --es action "$OPT_ACTION"; fi
84 if [ -n "$OPT_BUTTON1_ACTION" ]; then set -- "$@" --es button_action_1 "$OPT_BUTTON1_ACTION"; fi
85 if [ -n "$OPT_BUTTON1_TEXT" ]; then set -- "$@" --es button_text_1 "$OPT_BUTTON1_TEXT"; fi
86 if [ -n "$OPT_BUTTON2_ACTION" ]; then set -- "$@" --es button_action_2 "$OPT_BUTTON2_ACTION"; fi
87 if [ -n "$OPT_BUTTON2_TEXT" ]; then set -- "$@" --es button_text_2 "$OPT_BUTTON2_TEXT"; fi
88 if [ -n "$OPT_BUTTON3_ACTION" ]; then set -- "$@" --es button_action_3 "$OPT_BUTTON3_ACTION"; fi
89 if [ -n "$OPT_BUTTON3_TEXT" ]; then set -- "$@" --es button_text_3 "$OPT_BUTTON3_TEXT"; fi
90 if [ -n "$OPT_ID" ]; then set -- "$@" --es id "$OPT_ID"; fi
91 if [ -n "$OPT_LED_COLOR" ]; then set -- "$@" --es led-color "$OPT_LED_COLOR"; fi
92 if [ -n "$OPT_LED_OFF" ]; then set -- "$@" --ei led-off "$OPT_LED_OFF"; fi
93 if [ -n "$OPT_LED_ON" ]; then set -- "$@" --ei led-on "$OPT_LED_ON"; fi
94 if [ -n "$OPT_PRIORITY" ]; then set -- "$@" --es priority "$OPT_PRIORITY"; fi
95 if [ -n "$OPT_SOUND" ]; then set -- "$@" --ez sound "$OPT_SOUND"; fi
96 if [ -n "$OPT_TITLE" ]; then set -- "$@" --es title "$OPT_TITLE"; fi
97 if [ -n "$OPT_VIBRATE" ]; then set -- "$@" --ela vibrate "$OPT_VIBRATE"; fi
98
99 if [ -v OPT_CONTENT ]; then
100 # Note that we want to accept an empty content (--content "").
101 echo ${OPT_CONTENT:=""} | /data/data/com.termux/files/usr/libexec/termux-api Notification "$@"
102 else
103 /data/data/com.termux/files/usr/libexec/termux-api Notification "$@"
104 fi