librhash: Update from 1.3.5 to 1.3.6
[termux-packages] / packages / termux-tools / termux-open
CommitLineData
12d3fff0
FF
1#!/data/data/com.termux/files/usr/bin/sh
2set -e -u
3
4SCRIPTNAME=termux-open
5show_usage () {
6 echo "Usage: $SCRIPTNAME [options] path-or-url"
7 echo "Open a file or URL in an external app."
8 echo " --send if the file should be shared for sending"
9 echo " --view if the file should be shared for viewing (default)"
10 echo " --chooser if an app chooser should always be shown"
11 echo " --content-type type specify the content type to use"
12 exit 0
13}
14
15TEMP=`busybox getopt \
16 -n $SCRIPTNAME \
17 -o h \
bd78c57f 18 --long send,view,chooser,content-type:,help\
12d3fff0
FF
19 -- "$@"`
20eval set -- "$TEMP"
21
22ACTION=android.intent.action.VIEW
23EXTRAS=""
24while true; do
25 case "$1" in
26 --send) ACTION="android.intent.action.SEND"; shift;;
27 --view) ACTION="android.intent.action.VIEW"; shift;;
28 --chooser) EXTRAS="$EXTRAS --ez chooser true"; shift;;
29 --content-type) EXTRAS="$EXTRAS --es content-type $2"; shift 2;;
30 -h | --help) show_usage;;
31 --) shift; break ;;
32 esac
33done
34if [ $# != 1 ]; then
35 show_usage
36fi
37
83686ac5
FF
38FILE="$1"
39if [ -f "$FILE" ]; then
40 FILE=`realpath "$FILE"`
41fi
42
12d3fff0
FF
43am broadcast --user 0 \
44 -a $ACTION \
45 -n com.termux/com.termux.app.TermuxOpenReceiver \
46 $EXTRAS \
83686ac5 47 -d "$FILE" \
12d3fff0
FF
48 > /dev/null
49