termux-vibrate: Cleanup
This commit is contained in:
parent
3b43db5d96
commit
c3c912e687
@ -1,27 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e -u
|
||||
|
||||
SCRIPTNAME=termux-vibrate
|
||||
show_usage () {
|
||||
echo 'usage: termux-vibrate [-f,--force] [-d,--duration <duration_ms>]'
|
||||
echo 'Vibrate the device for the specified duration (default:1000 ms).'
|
||||
echo ''
|
||||
echo 'By default no vibration is done when in silent mode - use the'
|
||||
echo '-f,--force option to force vibration even when in silent mode.'
|
||||
exit 1
|
||||
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
|
||||
}
|
||||
|
||||
PARAM_DURATION=""
|
||||
O=`getopt -l duration: -l force -l help -- d:fh "$@"`
|
||||
eval set -- "$O"
|
||||
while true; do
|
||||
case "$1" in
|
||||
-d|--duration) PARAM_DURATION="--ei duration_ms $2"; shift 2;;
|
||||
-f|--force) PARAM_DURATION="--ez force true"; shift 1;;
|
||||
-h|--help) show_usage;;
|
||||
--) shift; break;;
|
||||
*) echo Error; exit 1;;
|
||||
esac
|
||||
done
|
||||
PARAMS=""
|
||||
|
||||
@TERMUX_API@ Vibrate $PARAM_DURATION
|
||||
while getopts :hfd: option
|
||||
do
|
||||
case "$option" in
|
||||
h) show_usage;;
|
||||
d) PARAMS="$PARAMS --ei duration_ms $OPTARG";;
|
||||
f) PARAMS="$PARAMS --ez force true";;
|
||||
?) 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@ Vibrate $PARAMS
|
||||
|
Loading…
Reference in New Issue
Block a user