chiark / gitweb /
43a062c502f1cf0a044eb3609d3e3f293c993a89
[termux-packages] / packages / termux-api / termux-toast
1 #!/bin/sh
2 set -e -u
3
4 SCRIPTNAME=termux-toast
5 show_usage () {
6     echo "Usage: termux-toast [-s] [text]"
7     echo "Show text in a Toast (a transient popup). The text to show is either supplied as arguments or read from stdin if no arguments are given."
8     echo ""
9     echo " -s  only show the toast for a short while"
10     echo ""
11     exit 0
12 }
13
14 PARAMS=""
15 while getopts :hs option
16 do
17     case "$option" in
18         h) show_usage;;
19         s) PARAMS="--ez short true";;
20         ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
21     esac
22 done
23 shift $(($OPTIND-1))
24
25 CMD="@TERMUX_API@ Toast $PARAMS"
26 if [ $# = 0 ]; then
27     $CMD
28 else
29     echo $@ | $CMD
30 fi