-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamview.bash
More file actions
66 lines (60 loc) · 1.35 KB
/
camview.bash
File metadata and controls
66 lines (60 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# bash completion for camview — https://github.com/lenik/picam
_camview_has_still() {
local w
for w in "${words[@]:0:cword}"; do
if [[ $w == -s || $w == --still ]]; then
return 0
fi
done
return 1
}
_camview_has_duration() {
local w
for w in "${words[@]:0:cword}"; do
if [[ $w == -d || $w == --duration ]]; then
return 0
fi
done
return 1
}
_camview() {
local cur prev words cword
_init_completion || return
case $prev in
-d|--duration)
COMPREPLY=($(compgen -W '5s 10s 30s 1min 2min 500ms 1hr' -- "$cur"))
return
;;
-f|--format)
if _camview_has_still; then
COMPREPLY=($(compgen -W 'jpg jpeg png' -- "$cur"))
elif _camview_has_duration; then
COMPREPLY=($(compgen -W 'mp4 mov mkv' -- "$cur"))
else
COMPREPLY=($(compgen -W 'jpg jpeg png mp4 mov mkv' -- "$cur"))
fi
return
;;
-i|--device)
COMPREPLY=($(compgen -W '1 2' -- "$cur"))
return
;;
-o|--output)
_filedir
return
;;
--camera-name|-r|--resolution|--framerate|--jpeg-quality|--af-settle-ms)
return
;;
esac
if [[ $cur == -* ]]; then
local opts='-v -q -h -s -d -f -o -i -r
--verbose --quiet --help --version
--still --duration --format --output --device --camera-name
--resolution --framerate --jpeg-quality --af-settle-ms
--no-autofocus --headless'
COMPREPLY=($(compgen -W "$opts" -- "$cur"))
return
fi
}
complete -F _camview camview