termux-api.c: rand() -> arc4random()
[termux-packages] / packages / termux-api / termux-camera-photo
CommitLineData
cc1ae02e 1#!/bin/sh
59f0d218
FF
2
3set -e -u
4
59f0d218 5show_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 13PARAMS=""
59f0d218
FF
14O=`getopt -l camera: -l help -l size -- c:hs: "$@"`
15eval set -- "$O"
16while true; do
17case "$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;;
23esac
24done
25
2e395b58
FF
26if [ $# != 1 ]; then show_usage; exit 1; fi
27
59f0d218 28touch $1
2aa217bf 29PARAMS="$PARAMS --es file `realpath $1`"
59f0d218 30
cc1ae02e 31@TERMUX_API@ CameraPhoto $PARAMS