@@ -6,77 +6,107 @@ show_usage () {
66 echo " Usage: termux-notification [options]"
77 echo " Display a system notification. Content text is read from stdin or specified using --content."
88 echo " --action action action to execute when pressing the notification"
9+ echo " --alert-once do not alert when the notification is edited"
910 echo " --button1 text text to show on the first notification button"
1011 echo " --button1-action action action to execute on the first notification button"
1112 echo " --button2 text text to show on the second notification button"
1213 echo " --button2-action action action to execute on the second notification button"
1314 echo " --button3 text text to show on the third notification button"
1415 echo " --button3-action action action to execute on the third notification button"
1516 echo " --content content content to show in the notification. Will take precedence over stdin."
17+ echo " --group group notification group (notifications with the same group are shown together)"
1618 echo " --id id notification id (will overwrite any previous notification with the same id)"
19+ echo " --image-path path absolute path to an image which will be shown in the notification"
1720 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)"
1921 echo " --led-off milliseconds number of milliseconds for the LED to be off while it's flashing (default: 800)"
22+ echo " --led-on milliseconds number of milliseconds for the LED to be on while it's flashing (default: 800)"
2023 echo " --on-delete action action to execute when the the notification is cleared"
24+ echo " --ongoing pin the notification"
2125 echo " --priority prio notification priority (high/low/max/min/default)"
2226 echo " --sound play a sound with the notification"
2327 echo " --title title notification title to show"
2428 echo " --vibrate pattern vibrate pattern, comma separated as in 500,1000,200"
29+ echo " --type type notification style to use (default/media)"
30+ echo " Media actions (available with --type \" media\" ):"
31+ echo " --media-next action to execute on the media-next button"
32+ echo " --media-pause action to execute on the media-pause button"
33+ echo " --media-play action to execute on the media-play button"
34+ echo " --media-previous action to execute on the media-previous button"
2535 exit 0
2636}
2737
2838OPT_ACTION=" "
39+ OPT_ALERT_ONCE=" "
40+ OPT_BUTTON1_ACTION=" "
41+ OPT_BUTTON1_TEXT=" "
42+ OPT_BUTTON2_ACTION=" "
43+ OPT_BUTTON2_TEXT=" "
44+ OPT_BUTTON3_ACTION=" "
45+ OPT_BUTTON3_TEXT=" "
46+ OPT_CONTENT=" "
47+ OPT_GROUP=" "
2948OPT_ID=" "
49+ OPT_IMAGE_PATH=" "
3050OPT_LED_COLOR=" "
3151OPT_LED_OFF=" "
3252OPT_LED_ON=" "
53+ OPT_MEDIA_NEXT=" "
54+ OPT_MEDIA_PAUSE=" "
55+ OPT_MEDIA_PLAY=" "
56+ OPT_MEDIA_PREVIOUS=" "
57+ OPT_ONGOING=" "
3358OPT_ON_DELETE_ACTION=" "
3459OPT_PRIORITY=" "
3560OPT_SOUND=" "
3661OPT_TITLE=" "
62+ OPT_TYPE=" "
3763OPT_VIBRATE=" "
38- OPT_BUTTON1_TEXT=" "
39- OPT_BUTTON1_ACTION=" "
40- OPT_BUTTON2_TEXT=" "
41- OPT_BUTTON2_ACTION=" "
42- OPT_BUTTON3_TEXT=" "
43- OPT_BUTTON3_ACTION=" "
44- OPT_CONTENT=" "
4564
4665TEMP=` busybox getopt \
4766 -n $SCRIPTNAME \
4867 -o hc:i:t: \
49- --long action:,\
68+ --long action:,alert-once, \
5069button1:,button1-action:,\
5170button2:,button2-action:,\
5271button3:,button3-action:,\
53- content:,help,id:,\
72+ content:,group:, help,id:,image-path: \
5473led-color:,led-on:,led-off:,\
55- on-delete:,\
56- priority:,sound,title:,vibrate: \
74+ media-previous:,media-next:,media-play:,media-pause:,\
75+ on-delete:,ongoing,\
76+ priority:,\
77+ sound,title:,type:,vibrate: \
5778 -s bash \
5879 -- " $@ " `
5980eval set -- " $TEMP "
6081
6182while true ; do
6283 case " $1 " in
6384 --action) OPT_ACTION=" $2 " ; shift 2;;
85+ --alert-once) OPT_ALERT_ONCE=" true" ; shift 1;;
6486 --button1) OPT_BUTTON1_TEXT=" $2 " ; shift 2;;
6587 --button1-action) OPT_BUTTON1_ACTION=" $2 " ; shift 2;;
6688 --button2) OPT_BUTTON2_TEXT=" $2 " ; shift 2;;
6789 --button2-action) OPT_BUTTON2_ACTION=" $2 " ; shift 2;;
6890 --button3) OPT_BUTTON3_TEXT=" $2 " ; shift 2;;
6991 --button3-action) OPT_BUTTON3_ACTION=" $2 " ; shift 2;;
7092 -c | --content) OPT_CONTENT=" $2 " ; shift 2;;
93+ --group) OPT_GROUP=" $2 " ; shift 2;;
7194 -h | --help) show_usage;;
7295 -i | --id) OPT_ID=" $2 " ; shift 2;;
96+ --image-path) OPT_IMAGE_PATH=" $2 " ; shift 2;;
7397 --led-color) OPT_LED_COLOR=" $2 " ; shift 2;;
74- --led-on) OPT_LED_ON=" $2 " ; shift 2;;
7598 --led-off) OPT_LED_OFF=" $2 " ; shift 2;;
99+ --led-on) OPT_LED_ON=" $2 " ; shift 2;;
100+ --media-next) OPT_MEDIA_NEXT=" $2 " ; shift 2;;
101+ --media-pause) OPT_MEDIA_PAUSE=" $2 " ; shift 2;;
102+ --media-play) OPT_MEDIA_PLAY=" $2 " ; shift 2;;
103+ --media-previous) OPT_MEDIA_PREVIOUS=" $2 " ; shift 2;;
76104 --on-delete) OPT_ON_DELETE_ACTION=" $2 " ; shift 2;;
105+ --ongoing) OPT_ONGOING=" true" ; shift 1;;
77106 --priority) OPT_PRIORITY=" $2 " ; shift 2;;
78107 --sound) OPT_SOUND=" true" ; shift 1;;
79108 -t | --title) OPT_TITLE=" $2 " ; shift 2;;
109+ --type) OPT_TYPE=" $2 " ; shift 2;;
80110 --vibrate) OPT_VIBRATE=" $2 " ; shift 2;;
81111 --) shift ; break ;;
82112 esac
@@ -86,20 +116,29 @@ if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
86116
87117set --
88118if [ -n " $OPT_ACTION " ]; then set -- " $@ " --es action " $OPT_ACTION " ; fi
119+ if [ -n " $OPT_ALERT_ONCE " ]; then set -- " $@ " --ez alert-once " $OPT_ALERT_ONCE " ; fi
89120if [ -n " $OPT_BUTTON1_ACTION " ]; then set -- " $@ " --es button_action_1 " $OPT_BUTTON1_ACTION " ; fi
90121if [ -n " $OPT_BUTTON1_TEXT " ]; then set -- " $@ " --es button_text_1 " $OPT_BUTTON1_TEXT " ; fi
91122if [ -n " $OPT_BUTTON2_ACTION " ]; then set -- " $@ " --es button_action_2 " $OPT_BUTTON2_ACTION " ; fi
92123if [ -n " $OPT_BUTTON2_TEXT " ]; then set -- " $@ " --es button_text_2 " $OPT_BUTTON2_TEXT " ; fi
93124if [ -n " $OPT_BUTTON3_ACTION " ]; then set -- " $@ " --es button_action_3 " $OPT_BUTTON3_ACTION " ; fi
94125if [ -n " $OPT_BUTTON3_TEXT " ]; then set -- " $@ " --es button_text_3 " $OPT_BUTTON3_TEXT " ; fi
126+ if [ -n " $OPT_GROUP " ]; then set -- " $@ " --es group " $OPT_GROUP " ; fi
95127if [ -n " $OPT_ID " ]; then set -- " $@ " --es id " $OPT_ID " ; fi
128+ if [ -n " $OPT_IMAGE_PATH " ]; then set -- " $@ " --es image-path " $OPT_IMAGE_PATH " ; fi
96129if [ -n " $OPT_LED_COLOR " ]; then set -- " $@ " --es led-color " $OPT_LED_COLOR " ; fi
97130if [ -n " $OPT_LED_OFF " ]; then set -- " $@ " --ei led-off " $OPT_LED_OFF " ; fi
98131if [ -n " $OPT_LED_ON " ]; then set -- " $@ " --ei led-on " $OPT_LED_ON " ; fi
132+ if [ -n " $OPT_MEDIA_NEXT " ]; then set -- " $@ " --es media-next " $OPT_MEDIA_NEXT " ; fi
133+ if [ -n " $OPT_MEDIA_PAUSE " ]; then set -- " $@ " --es media-pause " $OPT_MEDIA_PAUSE " ; fi
134+ if [ -n " $OPT_MEDIA_PLAY " ]; then set -- " $@ " --es media-play " $OPT_MEDIA_PLAY " ; fi
135+ if [ -n " $OPT_MEDIA_PREVIOUS " ]; then set -- " $@ " --es media-previous " $OPT_MEDIA_PREVIOUS " ; fi
136+ if [ -n " $OPT_ONGOING " ]; then set -- " $@ " --ez ongoing " $OPT_ONGOING " ; fi
99137if [ -n " $OPT_ON_DELETE_ACTION " ]; then set -- " $@ " --es on_delete_action " $OPT_ON_DELETE_ACTION " ; fi
100138if [ -n " $OPT_PRIORITY " ]; then set -- " $@ " --es priority " $OPT_PRIORITY " ; fi
101139if [ -n " $OPT_SOUND " ]; then set -- " $@ " --ez sound " $OPT_SOUND " ; fi
102140if [ -n " $OPT_TITLE " ]; then set -- " $@ " --es title " $OPT_TITLE " ; fi
141+ if [ -n " $OPT_TYPE " ]; then set -- " $@ " --es type " $OPT_TYPE " ; fi
103142if [ -n " $OPT_VIBRATE " ]; then set -- " $@ " --ela vibrate " $OPT_VIBRATE " ; fi
104143
105144# Note that we want to accept an empty content (--content "").
0 commit comments