Skip to content

Commit d803d16

Browse files
xalexalexfornwall
authored andcommitted
termux-notification: allow using STDIN as content
... without hanging the script fixes termux/termux-api#271 and #71
1 parent d9e1d69 commit d803d16

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

scripts/termux-notification

100755100644
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,10 @@ if [ -n "$OPT_TITLE" ]; then set -- "$@" --es title "$OPT_TITLE"; fi
141141
if [ -n "$OPT_TYPE" ]; then set -- "$@" --es type "$OPT_TYPE"; fi
142142
if [ -n "$OPT_VIBRATE" ]; then set -- "$@" --ela vibrate "$OPT_VIBRATE"; fi
143143

144-
echo "$OPT_CONTENT" | /data/data/com.termux/files/usr/libexec/termux-api Notification "$@"
144+
if [ -n "$OPT_CONTENT" ] || [ -t 0 ]; then
145+
# we either have some content, so it takes precedence over STDIN
146+
# or have no STDIN, so we must use content even if empty
147+
echo "$OPT_CONTENT" | /data/data/com.termux/files/usr/libexec/termux-api Notification "$@"
148+
else # use STDIN
149+
/data/data/com.termux/files/usr/libexec/termux-api Notification "$@"
150+
fi

0 commit comments

Comments
 (0)