Skip to content

Commit 3e2a967

Browse files
authored
Merge pull request #28 from dkramer95/coloredToast
Add text color, bg color, and gravity options to termux-toast
2 parents 15682e0 + b6822c0 commit 3e2a967

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

scripts/termux-toast

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
1-
#!/data/data/com.termux/files/usr/bin/sh
1+
#!/data/data/com.termux/files/usr/bin/bash
22
set -e -u
33

44
SCRIPTNAME=termux-toast
55
show_usage () {
6-
echo "Usage: termux-toast [-s] [text]"
6+
echo "Usage: termux-toast [-b bgcolor] [-c color] [-g gravity] [-s] [text]"
77
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 " -h show this help"
9+
echo " -b set background color (default: gray)"
10+
echo " -c set text color (default: white)"
11+
echo " -g set position of toast: [top, middle, or bottom] (default: middle)"
812
echo " -s only show the toast for a short while"
13+
echo "NOTE: color can be a standard name (i.e. red) or 6 / 8 digit hex value (i.e. \"#FF0000\" or \"#FFFF0000\") where order is (AA)RRGGBB. Invalid color will revert to default value"
914
exit 0
1015
}
1116

1217
PARAMS=""
13-
while getopts :hs option
18+
while getopts :hsc:b:g: option
1419
do
1520
case "$option" in
1621
h) show_usage;;
17-
s) PARAMS="--ez short true";;
22+
s) PARAMS=" --ez short true";;
23+
c) PARAMS+=" --es text_color $OPTARG";;
24+
b) PARAMS+=" --es background $OPTARG";;
25+
g) PARAMS+=" --es gravity $OPTARG";;
1826
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
1927
esac
2028
done
2129
shift $(($OPTIND-1))
2230

2331
CMD="/data/data/com.termux/files/usr/libexec/termux-api Toast $PARAMS"
32+
2433
if [ $# = 0 ]; then
2534
$CMD
2635
else

0 commit comments

Comments
 (0)