Fredrik Fornwall
9 years ago
17 changed files with 269 additions and 211 deletions
@ -1,9 +1,23 @@ |
|||||
#!/bin/sh |
#!/bin/sh |
||||
|
set -e -u |
||||
|
|
||||
if [ "$#" != "0" ]; then |
SCRIPTNAME=termux-battery-status |
||||
echo "usage: termux-battery-status" |
show_usage () { |
||||
echo "Get the status of the device battery." |
echo "Usage: $SCRIPTNAME" |
||||
exit 1 |
echo "Get the status of the device battery." |
||||
fi |
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 |
@TERMUX_API@ BatteryStatus |
||||
|
@ -1,3 +1,23 @@ |
|||||
#!/bin/sh |
#!/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 |
@TERMUX_API@ CameraInfo |
||||
|
@ -1,10 +1,23 @@ |
|||||
#!/bin/sh |
#!/bin/sh |
||||
set -e -u |
set -e -u |
||||
|
|
||||
if [ "$#" != "0" ]; then |
SCRIPTNAME=termux-contact-list |
||||
echo "usage: termux-contact-list" |
show_usage () { |
||||
echo "List all contacts." |
echo "Usage: $SCRIPTNAME" |
||||
exit |
echo "List all contacts." |
||||
fi |
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 |
@TERMUX_API@ ContactList |
||||
|
@ -1,28 +1,30 @@ |
|||||
#!/bin/sh |
#!/bin/sh |
||||
set -e -u |
set -e -u |
||||
|
|
||||
PARAMS="" |
SCRIPTNAME=termux-notification |
||||
show_usage () { |
show_usage () { |
||||
echo "usage: termux-location [OPTIONS]" |
echo "usage: $SCRIPTNAME [-p provider] [-r request]" |
||||
echo "Get the device location. Options:" |
echo "Get the device location." |
||||
echo " -r, --request kind of request(s) to make [once/last/updates] (default: once)" |
echo "" |
||||
echo " -p, --provider location provider [gps/network/passive] (default: gps)" |
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: "$@"` |
PARAMS="" |
||||
if [ $? != 0 ] ; then show_usage; exit 1 ; fi |
|
||||
eval set -- "$O" |
while getopts :hr:p: option |
||||
while true; do |
do |
||||
case "$1" in |
case "$option" in |
||||
-h|--help) show_usage; exit 0;; |
h) show_usage;; |
||||
-r|--request) PARAMS="$PARAMS --es request $2"; shift 2;; |
r) PARAMS="$PARAMS --es request $OPTARG";; |
||||
-p|--provider) PARAMS="$PARAMS --es provider $2"; shift 2;; |
p) PARAMS="$PARAMS --es provider $OPTARG";; |
||||
--) shift; break;; |
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; |
||||
*) echo Error; show_usage; exit 1;; |
esac |
||||
esac |
|
||||
done |
done |
||||
|
shift $(($OPTIND-1)) |
||||
|
|
||||
# Too many arguments: |
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi |
||||
if [ $# != 0 ]; then show_usage; exit 1; fi |
|
||||
|
|
||||
@TERMUX_API@ Location $PARAMS |
@TERMUX_API@ Location $PARAMS |
||||
|
@ -1,52 +1,51 @@ |
|||||
#!/bin/sh |
#!/bin/sh |
||||
|
set -e -u |
||||
|
|
||||
|
SCRIPTNAME=termux-share |
||||
show_usage () { |
show_usage () { |
||||
echo "usage: termux-share [options] [file]" |
echo "Usage: $SCRIPTNAME [-a action] [-c content-type] [-d] [-t title] [file]" |
||||
echo "Share a file specified as argument or the stdin as text input." |
echo "Share a file specified as argument or the text received on stdin if no file argument is given." |
||||
echo "Options:" |
echo "" |
||||
echo " -a, --action which action to performed on the shared content: edit/send/view (default:view)" |
echo " -a action which action to performed on the shared content:" |
||||
echo " -d, --default share to the default receiver if one is selected (instead of showing a chooser)" |
echo " edit/send/view (default:view)" |
||||
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," |
||||
echo " -c, --content-type content-type to use (default: guessed from file extension, text/plain for stdin)" |
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 () { |
validate_share () { |
||||
SHARETYPE=$1 |
SHARETYPE=$1 |
||||
case "$SHARETYPE" in |
case "$SHARETYPE" in |
||||
edit) |
edit) ;; |
||||
;; |
send) ;; |
||||
send) |
view) ;; |
||||
;; |
*) echo "$SCRIPTNAME: Unsupported action: '$SHARETYPE'"; exit 1;; |
||||
view) |
esac |
||||
;; |
|
||||
*) |
|
||||
echo "Unsupported action: '$SHARETYPE' - only edit/send/view available" |
|
||||
exit 1 |
|
||||
;; |
|
||||
esac |
|
||||
} |
} |
||||
|
|
||||
PARAMS="" |
PARAMS="" |
||||
O=`busybox getopt -q -l action: -l content-type: -l default -l help -l mimetype -l title: -- a:c:dht: "$@"` |
while getopts :ha:c:dt: option |
||||
if [ $? != 0 ] ; then show_usage; exit 1 ; fi |
do |
||||
eval set -- "$O" |
case "$option" in |
||||
while true; do |
h) show_usage;; |
||||
case "$1" in |
a) validate_share $OPTARG; PARAMS="$PARAMS --es action $OPTARG";; |
||||
-a|--action) validate_share $2; PARAMS="$PARAMS --es action $2"; shift 2;; |
c) PARAMS="$PARAMS --es content-type $OPTARG";; |
||||
-c|--content-type) PARAMS="$PARAMS --es content-type $2"; shift 2;; |
d) PARAMS="$PARAMS --ez default-receiver true";; |
||||
-d|--default) PARAMS="$PARAMS --ez default-receiver true"; shift 1;; |
t) PARAMS="$PARAMS --es title $OPTARG";; |
||||
-h|--help) show_usage; exit 0;; |
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; |
||||
-t|--title) PARAMS="$PARAMS --es title $2"; shift 2;; |
esac |
||||
--) shift; break;; |
|
||||
*) echo Error; exit 1;; |
|
||||
esac |
|
||||
done |
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 |
if [ $# != 0 ]; then |
||||
# Note that the file path can contain whitespace. |
# Note that the file path can contain whitespace. |
||||
@TERMUX_API@ Share $PARAMS --es file "`realpath "$1"`" |
@TERMUX_API@ Share $PARAMS --es file "`realpath "$1"`" |
||||
else |
else |
||||
@TERMUX_API@ Share $PARAMS |
@TERMUX_API@ Share $PARAMS |
||||
fi |
fi |
||||
|
@ -1,24 +1,30 @@ |
|||||
#!/bin/sh |
#!/bin/sh |
||||
|
set -e -u |
||||
|
|
||||
|
SCRIPTNAME=termux-toast |
||||
show_usage () { |
show_usage () { |
||||
echo "usage: termux-toast [-s|--short]" |
echo "Usage: termux-toast [-s] [text]" |
||||
echo "Show the text from stdin in a Toast (a transient popup). Options:" |
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 " -s, --short only show the toast for a short while" |
echo "" |
||||
|
echo " -s only show the toast for a short while" |
||||
|
echo "" |
||||
|
exit 0 |
||||
} |
} |
||||
|
|
||||
PARAMS="" |
PARAMS="" |
||||
O=`busybox getopt -q -l short -l help -- sh "$@"` |
while getopts :hs option |
||||
if [ $? != 0 ] ; then show_usage; exit 1 ; fi |
do |
||||
eval set -- "$O" |
case "$option" in |
||||
while true; do |
h) show_usage;; |
||||
case "$1" in |
s) PARAMS="--ez short true";; |
||||
-s|--short) PARAMS="$PARAMS --ez short true"; shift 1;; |
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; |
||||
-h|--help) show_usage; exit 0;; |
esac |
||||
--) shift; break;; |
|
||||
*) echo Error; exit 1;; |
|
||||
esac |
|
||||
done |
done |
||||
|
shift $(($OPTIND-1)) |
||||
|
|
||||
if [ $# != 0 ]; then show_usage; exit 1; fi |
CMD="@TERMUX_API@ Toast $PARAMS" |
||||
|
if [ $# = 0 ]; then |
||||
@TERMUX_API@ Toast $PARAMS |
$CMD |
||||
|
else |
||||
|
echo $@ | $CMD |
||||
|
fi |
||||
|
Loading…
Reference in new issue