chiark / gitweb /
termux-api: Cleanup and improve consistency
authorFredrik Fornwall <fredrik@fornwall.net>
Mon, 25 Apr 2016 23:37:45 +0000 (01:37 +0200)
committerFredrik Fornwall <fredrik@fornwall.net>
Mon, 25 Apr 2016 23:37:45 +0000 (01:37 +0200)
17 files changed:
packages/termux-api/termux-battery-status
packages/termux-api/termux-camera-info
packages/termux-api/termux-camera-photo
packages/termux-api/termux-clipboard-get
packages/termux-api/termux-clipboard-set
packages/termux-api/termux-contact-list
packages/termux-api/termux-dialog
packages/termux-api/termux-download
packages/termux-api/termux-location
packages/termux-api/termux-notification
packages/termux-api/termux-share
packages/termux-api/termux-sms-inbox
packages/termux-api/termux-sms-send
packages/termux-api/termux-toast
packages/termux-api/termux-tts-engines
packages/termux-api/termux-tts-speak
packages/termux-api/termux-vibrate

index 4441d48af4a0b50d90494d124d274398114036a0..fbdb8af2d9487da2adec154e264e6b5b3f832cc9 100755 (executable)
@@ -1,9 +1,23 @@
 #!/bin/sh
+set -e -u
 
-if [ "$#" != "0" ]; then
-       echo "usage: termux-battery-status"
-       echo "Get the status of the device battery."
-       exit 1
-fi
+SCRIPTNAME=termux-battery-status
+show_usage () {
+    echo "Usage: $SCRIPTNAME"
+    echo "Get the status of the device battery."
+    echo ""
+    exit 0
+}
+
+while getopts :h option
+do
+    case "$option" in
+        h) show_usage;;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
+done
+shift $(($OPTIND-1))
+
+if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
 
 @TERMUX_API@ BatteryStatus
index ec6bda1f740f4d6389c70909662d472128671061..79ec66e82d654116bcb085c1e5a20d858ddcfd65 100755 (executable)
@@ -1,3 +1,23 @@
 #!/bin/sh
+set -e -u
+
+SCRIPTNAME=termux-camera-info
+show_usage () {
+    echo "Usage: $SCRIPTNAME"
+    echo "Get information about device camera(s)."
+    echo ""
+    exit 0
+}
+
+while getopts :h option
+do
+    case "$option" in
+        h) show_usage;;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
+done
+shift $(($OPTIND-1))
+
+if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
 
 @TERMUX_API@ CameraInfo
index bdb27a5aa8f4d09eec97a5d0eed27b7c48a5c35a..7b3836fff9b76b53e3f3d393217786bf5a4dd65c 100755 (executable)
@@ -1,29 +1,30 @@
 #!/bin/sh
-
 set -e -u
 
+SCRIPTNAME=termux-camera-photo
 show_usage () {
-       echo "usage: termux-camera-photo [OPTIONS] <output-file>"
-       echo ""
-       echo "Take a photo and save it in a file. Valid options:"
-       echo "  -c, --camera <camera-id>    the ID of the camera to use"
-       echo "Use termux-camera-info for information about available camera IDs."
+    echo "Usage: termux-camera-photo [-c camera-id] output-file"
+    echo "Take a photo and save it to a file in JPEG format."
+    echo ""
+    echo "  -c camera-id  ID of the camera to use (see termux-camera-info), default: 0"
+    echo ""
+    exit 0
 }
 
+
 PARAMS=""
-O=`getopt -l camera: -l help -l size -- c:hs: "$@"`
-eval set -- "$O"
-while true; do
-case "$1" in
-       -c|--camera) PARAMS="$PARAMS --es camera $2";  shift 2;;
-       -h|--help) show_usage; exit 0;;
-       -s|--size) PARAMS="$PARAMS --ei size_index $2";  shift 2;;
-       --)     shift; break;;
-       *)      echo Error; exit 1;;
-esac
+while getopts :hc: option
+do
+    case "$option" in
+        h) show_usage;;
+        c) PARAMS="--es camera $OPTARG";;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
 done
+shift $(($OPTIND-1))
 
-if [ $# != 1 ]; then show_usage; exit 1; fi
+if [ $# = 0 ]; then echo "$SCRIPTNAME: missing file argument"; exit 1; fi
+if [ $# != 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
 
 touch $1
 PARAMS="$PARAMS --es file `realpath $1`"
index 99ccc90ef982c41fa50e768ef8ad5618522ceb6b..d03fc515f2ae4bb73d3d01a5d8519dfc01c0e4d4 100755 (executable)
@@ -3,9 +3,10 @@ set -e -u
 
 SCRIPTNAME=termux-clipboard-get
 show_usage () {
-       echo "Usage: $SCRIPTNAME"
-       echo "Get the system clipboard text."
-       exit 0
+    echo "Usage: $SCRIPTNAME"
+    echo "Get the system clipboard text."
+    echo ""
+    exit 0
 }
 
 while getopts :h option
index 8486179baf550c8dbfb0539ad5d9d010676f8584..621674f4aa0ec995d5deb99676edca6bd7e5716a 100755 (executable)
@@ -3,12 +3,10 @@ set -e -u
 
 SCRIPTNAME=termux-clipboard-set
 show_usage () {
-       echo "Usage: $SCRIPTNAME <text>"
-       echo "Set the system clipboard text."
-       echo ""
-       echo "If no arguments are given the text to set is read from stdin,"
-       echo "otherwise all arguments given are used as the text to set."
-       exit 0
+    echo "Usage: $SCRIPTNAME [text]"
+    echo "Set the system clipboard text. The text to set is either supplied as arguments or read from stdin if no arguments are given."
+    echo ""
+    exit 0
 }
 
 while getopts :h option
index 8f38e0345039dff155313a15ef99453b9c230882..a1d979b492ddc88eb3127b4b1ad6099606d8844e 100755 (executable)
@@ -1,10 +1,23 @@
 #!/bin/sh
 set -e -u
 
-if [ "$#" != "0" ]; then
-       echo "usage: termux-contact-list"
-       echo "List all contacts."
-       exit
-fi
+SCRIPTNAME=termux-contact-list
+show_usage () {
+    echo "Usage: $SCRIPTNAME"
+    echo "List all contacts."
+    echo ""
+    exit 0
+}
+
+while getopts :h option
+do
+    case "$option" in
+        h) show_usage;;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
+done
+shift $(($OPTIND-1))
+
+if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
 
 @TERMUX_API@ ContactList
index c513f9442959ff6bfe587ade62a0559edadf6d29..2a244464d94a43203e4010c35df9249b8f42adac 100755 (executable)
@@ -3,14 +3,15 @@ set -e -u
 
 SCRIPTNAME=termux-dialog
 show_usage () {
-       echo "Usage: $SCRIPTNAME [OPTIONS]"
-       echo "Show a text entry dialog."
-       echo ""
-       echo "  -i <hint>   the input hint to show when the input is empty"
-       echo "  -m          use a textarea with multiple lines instead of a single"
-       echo "  -p          enter the input as a password"
-       echo "  -t <title>  the title to show for the input prompt"
-       exit 0
+    echo "Usage: $SCRIPTNAME [-i hint] [-m] [-p] [-t title]"
+    echo "Show a text entry dialog."
+    echo ""
+    echo "  -i hint   the input hint to show when the input is empty"
+    echo "  -m        use a textarea with multiple lines instead of a single"
+    echo "  -p        enter the input as a password"
+    echo "  -t title  the title to show for the input prompt"
+    echo ""
+    exit 0
 }
 
 PARAMS=""
index f8e3f976dc696777c8339754fa3c777f77245ff3..4f904d38b648ec5dc95f4f7594664fa9604985f1 100755 (executable)
@@ -3,12 +3,13 @@ set -e -u
 
 SCRIPTNAME=termux-download
 show_usage () {
-       echo "Usage: $SCRIPTNAME [OPTIONS] <url-to-download>"
-       echo "Download a resource using the system download manager."
-       echo ""
-       echo "  -d <description>  description for the download request notification"
-       echo "  -t <title>        title for the download request notification"
-       exit 0
+    echo "Usage: $SCRIPTNAME [-d description] [-t title] url-to-download"
+    echo "Download a resource using the system download manager."
+    echo ""
+    echo "  -d description  description for the download request notification"
+    echo "  -t title        title for the download request notification"
+    echo ""
+    exit 0
 }
 
 ARG_D=""
index 1c3e0fa0a6d7b25fb9b2a84543282fb601389e61..5c0b263e38dec5226e48237c9955c7ef074b7ae4 100755 (executable)
@@ -1,28 +1,30 @@
 #!/bin/sh
 set -e -u
 
-PARAMS=""
+SCRIPTNAME=termux-notification
 show_usage () {
-       echo "usage: termux-location [OPTIONS]"
-       echo "Get the device location. Options:"
-       echo "       -r, --request      kind of request(s) to make [once/last/updates] (default: once)"
-       echo "       -p, --provider     location provider [gps/network/passive] (default: gps)"
+    echo "usage: $SCRIPTNAME [-p provider] [-r request]"
+    echo "Get the device location."
+    echo ""
+    echo "  -p provider  location provider [gps/network/passive] (default: gps)"
+    echo "  -r request   kind of request to make [once/last/updates] (default: once)"
+    echo ""
+    exit 0
 }
 
-O=`busybox getopt -q -l request: -l provider: -- r:hp: "$@"`
-if [ $? != 0 ] ; then show_usage; exit 1 ; fi
-eval set -- "$O"
-while true; do
-case "$1" in
-       -h|--help) show_usage; exit 0;;
-       -r|--request) PARAMS="$PARAMS --es request $2"; shift 2;;
-       -p|--provider) PARAMS="$PARAMS --es provider $2"; shift 2;;
-       --)     shift; break;;
-       *)      echo Error; show_usage; exit 1;;
-esac
+PARAMS=""
+
+while getopts :hr:p: option
+do
+    case "$option" in
+        h) show_usage;;
+        r) PARAMS="$PARAMS --es request $OPTARG";;
+        p) PARAMS="$PARAMS --es provider $OPTARG";;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
 done
+shift $(($OPTIND-1))
 
-# Too many arguments:
-if [ $# != 0 ]; then show_usage; exit 1; fi
+if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
 
 @TERMUX_API@ Location $PARAMS
index 34a5aab3434269b5e9e5138473ff17aab5e9c12d..ecac9aeb9d4020c6d22fd7900688f279bda4e57e 100755 (executable)
@@ -3,14 +3,16 @@ set -e -u
 
 SCRIPTNAME=termux-notification
 show_usage () {
-       echo "Usage: termux-notification [OPTIONS]"
-       echo "Display a system notification."
-       echo ""
-       echo "  -c <content> notification content to show"
-       echo "  -i <id>      notification id (will overwrite the previous notification with the same id)"
-       echo "  -t <title>   notification title to show"
-       echo "  -u <url>     notification url when clicking on it"
-       exit 1
+    echo "Usage: termux-notification [-c content] [-i id] [-t title] [-u url]"
+    echo "Display a system notification."
+    echo ""
+    echo "  -c content notification content to show"
+    echo "  -i id      notification id (will overwrite any previous notification"
+    echo "               with the same id)"
+    echo "  -t title   notification title to show"
+    echo "  -u url     notification url when clicking on it"
+    echo ""
+    exit 0
 }
 
 CONTENT_OR_TITLE_SET=no
index 1c08188886864d3feab26ff65d94ef3be49aa442..fb3e8fbff5729a92bf838fc0fc6222bd98861ad9 100755 (executable)
@@ -1,52 +1,51 @@
 #!/bin/sh
+set -e -u
 
+SCRIPTNAME=termux-share
 show_usage () {
-       echo "usage: termux-share [options] [file]"
-       echo "Share a file specified as argument or the stdin as text input."
-       echo "Options:"
-       echo "       -a, --action          which action to performed on the shared content: edit/send/view (default:view)"
-       echo "       -d, --default         share to the default receiver if one is selected (instead of showing a chooser)"
-       echo "       -t, --title           title to use for shared content (default: shared file name)"
-       echo "       -c, --content-type    content-type to use (default: guessed from file extension, text/plain for stdin)"
+    echo "Usage: $SCRIPTNAME [-a action] [-c content-type] [-d] [-t title] [file]"
+    echo "Share a file specified as argument or the text received on stdin if no file argument is given."
+    echo ""
+    echo "  -a action        which action to performed on the shared content:"
+    echo "                     edit/send/view (default:view)"
+    echo "  -c content-type  content-type to use (default: guessed from file extension,"
+    echo "                     text/plain for stdin)"
+    echo "  -d               share to the default receiver if one is selected"
+    echo "                     instead of showing a chooser"
+    echo "  -t title         title to use for shared content (default: shared file name)"
+    echo ""
+    exit 0
 }
 
 validate_share () {
-       SHARETYPE=$1
-       case "$SHARETYPE" in 
-               edit)
-                       ;;
-               send)
-                       ;;
-               view)
-                       ;;
-               *)
-                       echo "Unsupported action: '$SHARETYPE' - only edit/send/view available"
-                       exit 1
-                       ;;
-       esac
+    SHARETYPE=$1
+    case "$SHARETYPE" in
+        edit) ;;
+        send) ;;
+        view) ;;
+        *) echo "$SCRIPTNAME: Unsupported action: '$SHARETYPE'"; exit 1;;
+    esac
 }
 
 PARAMS=""
-O=`busybox getopt -q -l action: -l content-type: -l default -l help -l mimetype -l title:  -- a:c:dht: "$@"`
-if [ $? != 0 ] ; then show_usage; exit 1 ; fi
-eval set -- "$O"
-while true; do
-case "$1" in
-       -a|--action) validate_share $2; PARAMS="$PARAMS --es action $2"; shift 2;;
-       -c|--content-type) PARAMS="$PARAMS --es content-type $2"; shift 2;;
-       -d|--default) PARAMS="$PARAMS --ez default-receiver true"; shift 1;;
-       -h|--help) show_usage; exit 0;;
-       -t|--title) PARAMS="$PARAMS --es title $2"; shift 2;;
-       --)     shift; break;;
-       *)      echo Error; exit 1;;
-esac
+while getopts :ha:c:dt: option
+do
+    case "$option" in
+        h) show_usage;;
+        a) validate_share $OPTARG; PARAMS="$PARAMS --es action $OPTARG";;
+        c) PARAMS="$PARAMS --es content-type $OPTARG";;
+        d) PARAMS="$PARAMS --ez default-receiver true";;
+        t) PARAMS="$PARAMS --es title $OPTARG";;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
 done
+shift $(($OPTIND-1))
 
-if [ $# -gt 1 ]; then echo "Only one file can be shared"; exit 1; fi
+if [ $# -gt 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
 
 if [ $# != 0 ]; then
-       # Note that the file path can contain whitespace.
-        @TERMUX_API@ Share $PARAMS --es file "`realpath "$1"`"
+    # Note that the file path can contain whitespace.
+    @TERMUX_API@ Share $PARAMS --es file "`realpath "$1"`"
 else
-       @TERMUX_API@ Share $PARAMS
+    @TERMUX_API@ Share $PARAMS
 fi
index 82b9f8bfd6a1df5d95f07d5a0f3df05d860c1744..ea109f392365140ec5fcdfc154e684829827e9ea 100755 (executable)
@@ -5,36 +5,33 @@ PARAM_LIMIT=10
 PARAM_OFFSET=0
 PARAMS=""
 
-SCRIPTNAME=$0
+SCRIPTNAME=termux-sms-inbox
 show_usage () {
-       echo "usage: termux-sms-inbox [OPTIONS]"
-       echo "List received SMS messages."
-       echo ""
-       echo "Options are all optional."
-       echo "       -d, --show-dates            show dates"
-       echo "       -n, --show-phone-numbers    show phone numbers"
-       echo "       -o, --offset                offset in sms list (default: $PARAM_OFFSET)"
-       echo "       -l, --limit                 offset in sms list (default: $PARAM_LIMIT)"
+    echo "Usage: termux-sms-inbox [-d] [-l limit] [-n] [-o offset]"
+    echo "List received SMS messages."
+    echo ""
+    echo "  -d         show dates when messages were created"
+    echo "  -l limit   offset in sms list (default: $PARAM_LIMIT)"
+    echo "  -n         show phone numbers"
+    echo "  -o offset  offset in sms list (default: $PARAM_OFFSET)"
+    echo ""
+    exit 0
 }
 
-O=`busybox getopt -q -l help -l show-dates -l show-phone-numbers -l limit: -l offset: -- dhl:no: "$@"`
-if [ $? != 0 ] ; then show_usage; exit 1 ; fi
-eval set -- "$O"
-while true; do
-case "$1" in
-       -h|--help) show_usage; exit 0;;
-       -l|--limit) PARAM_LIMIT=$2; shift 2;;
-       -o|--offset) PARAM_OFFSET=$2; shift 2;;
-       -d|--show-dates) PARAMS="$PARAMS --ez show-dates true"; shift;;
-       -n|--show-phone-numbers) PARAMS="$PARAMS --ez show-phone-numbers true"; shift;;
-       --)     shift; break;;
-       *)      echo Error; exit 1;;
-esac
+while getopts :hdl:no: option
+do
+    case "$option" in
+        h) show_usage;;
+        d) PARAMS="$PARAMS --ez show-dates true";;
+        l) PARAM_LIMIT=$OPTARG;;
+        n) PARAMS="$PARAMS --ez show-phone-numbers true";;
+        o) PARAM_OFFSET=$OPTARG;;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
 done
+shift $(($OPTIND-1))
 
-# Too many arguments:
-if [ $# != 0 ]; then show_usage; exit 1; fi
+if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
 
 PARAMS="$PARAMS --ei offset $PARAM_OFFSET --ei limit $PARAM_LIMIT"
-
 @TERMUX_API@ SmsInbox $PARAMS
index 7802b07b4ea356038793d66ddcb563fb25e73836..47902660203c45f99ba9cba00ea6d09771f59c76 100755 (executable)
@@ -3,33 +3,32 @@ set -e -u
 
 SCRIPTNAME=termux-sms-send
 show_usage () {
-       echo "Usage: $SCRIPTNAME [-t <text>] <recipient-number>"
-       echo "Send a SMS."
-       echo ""
-       echo "  -t <text>  text to send (optional - else from stdin)"
-       echo ""
-       echo "If no text is specified with the -t option the text to send is read from stdin."
-       exit 0
+    echo "Usage: $SCRIPTNAME -n number[,number2,number3,...] [text]"
+    echo "Send a SMS message to the specified recipient number(s). The text to send is either supplied as arguments or read from stdin if no arguments are given."
+    echo ""
+    echo "  -n number(s)  recipient number(s) - separate multiple numbers by commas"
+    echo ""
+    exit 0
 }
 
-TEXT_TO_SEND=""
-while getopts :ht: option
+RECIPIENTS=""
+while getopts :hn: option
 do
-       case "$option" in
-               h) show_usage;;
-               t) TEXT_TO_SEND="$OPTARG";;
-               ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
-       esac
+    case "$option" in
+        h) show_usage;;
+        n) RECIPIENTS="--esa recipients $OPTARG";;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
 done
 shift $(($OPTIND-1))
 
-if [ $# = 0 ]; then echo "$SCRIPTNAME: too few arguments"; exit 1; fi
-if [ $# -gt 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
+if [ -z "$RECIPIENTS" ]; then
+    echo "$SCRIPTNAME: no recipient number given"; exit 1;
+fi
 
-CMD="@TERMUX_API@ SmsSend --es recipient $1"
-if [ -z "$TEXT_TO_SEND" ]; then
-       $CMD
+CMD="@TERMUX_API@ SmsSend $RECIPIENTS"
+if [ $# = 0 ]; then
+    $CMD
 else
-       echo $TEXT_TO_SEND | $CMD
+    echo $@ | $CMD
 fi
-
index 247d09123b47af9d8b1068b08cf2758726f6b734..43a062c502f1cf0a044eb3609d3e3f293c993a89 100755 (executable)
@@ -1,24 +1,30 @@
 #!/bin/sh
+set -e -u
 
+SCRIPTNAME=termux-toast
 show_usage () {
-       echo "usage: termux-toast [-s|--short]"
-       echo "Show the text from stdin in a Toast (a transient popup). Options:"
-       echo "       -s, --short       only show the toast for a short while"
+    echo "Usage: termux-toast [-s] [text]"
+    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."
+    echo ""
+    echo " -s  only show the toast for a short while"
+    echo ""
+    exit 0
 }
 
 PARAMS=""
-O=`busybox getopt -q -l short -l help -- sh "$@"`
-if [ $? != 0 ] ; then show_usage; exit 1 ; fi
-eval set -- "$O"
-while true; do
-case "$1" in
-       -s|--short) PARAMS="$PARAMS --ez short true"; shift 1;;
-       -h|--help) show_usage; exit 0;;
-       --)     shift; break;;
-       *)      echo Error; exit 1;;
-esac
+while getopts :hs option
+do
+    case "$option" in
+        h) show_usage;;
+        s) PARAMS="--ez short true";;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
 done
+shift $(($OPTIND-1))
 
-if [ $# != 0 ]; then show_usage; exit 1; fi
-
-@TERMUX_API@ Toast $PARAMS
+CMD="@TERMUX_API@ Toast $PARAMS"
+if [ $# = 0 ]; then
+    $CMD
+else
+    echo $@ | $CMD
+fi
index 2d9831d990b27986fe2e592ccfc51ff8409fd574..9bdfd95c98ef3a130c1579f3b621b4e0f3e766de 100755 (executable)
@@ -3,11 +3,10 @@ set -e -u
 
 SCRIPTNAME=termux-tts-engines
 show_usage () {
-       echo "Usage: $SCRIPTNAME"
-       echo "Get information about the available text-to-speech (TTS) engines."
-       echo ""
-       echo "The name of an engine may be given to the termux-tts-speak command using the -e option."
-       exit 0
+    echo "Usage: $SCRIPTNAME"
+    echo "Get information about the available text-to-speech (TTS) engines. The name of an engine may be given to the termux-tts-speak command using the -e option."
+    echo ""
+    exit 0
 }
 
 while getopts :h option
index 4d58f22af276052bfd4dd5d03097c4a5568f45b3..70e49006b77026c6f6b542958eab536ab0b23516 100755 (executable)
@@ -3,41 +3,45 @@ set -e -u
 
 SCRIPTNAME=termux-tts-speak
 show_usage () {
-       echo "Usage: $SCRIPTNAME [OPTIONS] <text-to-speak>"
-       echo "Speak stdin input with a system text-to-speech (TTS) engine."
-       echo ""
-       echo "  -e <engine>   TTS engine to use (see 'termux-tts-engines')"
-       echo "  -l <language> language to speak in (may be unsupported by the engine)"
-       echo "  -p <pitch>    pitch to use in speech. 1.0 is the normal pitch,"
-       echo "                lower values lower the tone of the synthesized voice,"
-       echo "                greater values increase it."
-       echo "  -r <rate>     speech rate to use. 1.0 is the normal speech rate,"
-       echo "                lower values slow down the speech (0.5 is half the normal speech rate),"
-       echo "                greater values accelerate it ({@code 2.0} is twice the normal speech rate)."
-       echo ""
-       echo "The text to send can be specified either as arguments or on stdin if no arguments are given."
-       exit 0
+    echo "Usage: $SCRIPTNAME [-e engine] [-l language] [-p pitch] [-r rate] [-s stream] [text-to-speak]"
+    echo "Speak text with a system text-to-speech (TTS) engine. The text to speak is either supplied as arguments or read from stdin if no arguments are given."
+    echo ""
+    echo "  -e engine    TTS engine to use (see termux-tts-engines)"
+    echo "  -l language  language to speak in (may be unsupported by the engine)"
+    echo "  -p pitch     pitch to use in speech. 1.0 is the normal pitch,"
+    echo "                 lower values lower the tone of the synthesized voice,"
+    echo "                 greater values increase it."
+    echo "  -r rate      speech rate to use. 1.0 is the normal speech rate,"
+    echo "                 lower values slow down the speech"
+    echo "                 (0.5 is half the normal speech rate)"
+    echo "                 while greater values accelerates it"
+    echo "                 (2.0 is twice the normal speech rate)."
+    echo "  -s stream    audio stream to use (default:NOTIFICATION), one of:"
+    echo "                 ALARM, MUSIC, NOTIFICATION, RING, SYSTEM, VOICE_CALL"
+    echo ""
+    exit 0
 }
 
 PARAMS=""
 
-while getopts :he:l:p:r: option
+while getopts :he:l:p:r:s: option
 do
-       case "$option" in
-               h) show_usage;;
-               e) PARAMS="$PARAMS --es engine $OPTARG";;
-               l) PARAMS="$PARAMS --es language $OPTARG";;
-               p) PARAMS="$PARAMS --ef pitch $OPTARG";;
-               r) PARAMS="$PARAMS --ef rate $OPTARG";;
-               ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
-       esac
+    case "$option" in
+        h) show_usage;;
+        e) PARAMS="$PARAMS --es engine $OPTARG";;
+        l) PARAMS="$PARAMS --es language $OPTARG";;
+        p) PARAMS="$PARAMS --ef pitch $OPTARG";;
+        r) PARAMS="$PARAMS --ef rate $OPTARG";;
+        s) PARAMS="$PARAMS --es stream $OPTARG";;
+        ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
+    esac
 done
 shift $(($OPTIND-1))
 
 CMD="@TERMUX_API@ TextToSpeech $PARAMS"
 if [ $# = 0 ]; then
-       $CMD
+    $CMD
 else
-       echo $@ | $CMD
+    echo $@ | $CMD
 fi
 
index 4a0826eb1695829a0d5e4079222997f505af0a2d..ed973bf2760abd27fee12a79d76df4d7bcd1ebcd 100755 (executable)
@@ -3,12 +3,13 @@ set -e -u
 
 SCRIPTNAME=termux-vibrate
 show_usage () {
-       echo "Usage: $SCRIPTNAME [OPTIONS]"
-       echo "Vibrate the device."
-       echo ""
-       echo "  -d <duration_ms> the duration to vibrate in ms (default:1000)"
-       echo "  -f               force vibration even in silent mode"
-       exit 0
+    echo "Usage: $SCRIPTNAME [-d duration] [-f]"
+    echo "Vibrate the device."
+    echo ""
+    echo "  -d duration  the duration to vibrate in ms (default:1000)"
+    echo "  -f           force vibration even in silent mode"
+    echo ""
+    exit 0
 }
 
 PARAMS=""