Commit | Line | Data |
---|---|---|
cc1ae02e | 1 | #!/bin/sh |
59f0d218 FF |
2 | |
3 | set -e -u | |
4 | ||
59f0d218 | 5 | show_usage () { |
96015885 | 6 | echo "usage: termux-camera-photo [OPTIONS] <output-file>" |
59f0d218 FF |
7 | echo "" |
8 | echo "Take a photo and save it in a file. Valid options:" | |
96015885 FF |
9 | echo " -c, --camera <camera-id> the ID of the camera to use" |
10 | echo "Use termux-camera-info for information about available camera IDs." | |
59f0d218 FF |
11 | } |
12 | ||
2aa217bf | 13 | PARAMS="" |
59f0d218 FF |
14 | O=`getopt -l camera: -l help -l size -- c:hs: "$@"` |
15 | eval set -- "$O" | |
16 | while true; do | |
17 | case "$1" in | |
2e395b58 | 18 | -c|--camera) PARAMS="$PARAMS --es camera $2"; shift 2;; |
59f0d218 | 19 | -h|--help) show_usage; exit 0;; |
2aa217bf | 20 | -s|--size) PARAMS="$PARAMS --ei size_index $2"; shift 2;; |
59f0d218 FF |
21 | --) shift; break;; |
22 | *) echo Error; exit 1;; | |
23 | esac | |
24 | done | |
25 | ||
2e395b58 FF |
26 | if [ $# != 1 ]; then show_usage; exit 1; fi |
27 | ||
59f0d218 | 28 | touch $1 |
2aa217bf | 29 | PARAMS="$PARAMS --es file `realpath $1`" |
59f0d218 | 30 | |
cc1ae02e | 31 | @TERMUX_API@ CameraPhoto $PARAMS |