termux-api: Cleanup and improve consistency
[termux-packages] / packages / termux-api / termux-toast
CommitLineData
cc1ae02e 1#!/bin/sh
bea93fbd 2set -e -u
17d445b3 3
bea93fbd 4SCRIPTNAME=termux-toast
17d445b3 5show_usage () {
bea93fbd
FF
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
17d445b3
FF
12}
13
14PARAMS=""
bea93fbd
FF
15while getopts :hs option
16do
17 case "$option" in
18 h) show_usage;;
19 s) PARAMS="--ez short true";;
20 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
21 esac
17d445b3 22done
bea93fbd 23shift $(($OPTIND-1))
17d445b3 24
bea93fbd
FF
25CMD="@TERMUX_API@ Toast $PARAMS"
26if [ $# = 0 ]; then
27 $CMD
28else
29 echo $@ | $CMD
30fi