diff --git a/scripts/termux-battery-status.in b/scripts/termux-battery-status.in index 919535a..9e862e0 100644 --- a/scripts/termux-battery-status.in +++ b/scripts/termux-battery-status.in @@ -5,13 +5,16 @@ SCRIPTNAME=termux-battery-status show_usage () { echo "Usage: $SCRIPTNAME" echo "Get the status of the device battery." + echo " -t, set timeout for getting information (default: unlimited)" exit 0 } -while getopts :h option +TIMEOUT=0 +while getopts :ht: option do case "$option" in h) show_usage;; + t) TIMEOUT="$OPTARG";; ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; esac done @@ -19,4 +22,4 @@ shift $((OPTIND-1)) if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi -@TERMUX_PREFIX@/libexec/termux-api BatteryStatus +timeout --preserve-status "$TIMEOUT" @TERMUX_PREFIX@/libexec/termux-api BatteryStatus