Vendor the command set the menu and shell depend on
This commit is contained in:
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# blob:summary=List webcam devices that support video capture
|
||||
# blob:hidden=true
|
||||
|
||||
capture_capable() {
|
||||
local device="$1"
|
||||
|
||||
v4l2-ctl --device "$device" --info 2>/dev/null | awk '
|
||||
/^[[:space:]]*Device Caps[[:space:]]*:/ { inspect = 1; next }
|
||||
inspect && /^[[:space:]]*Video Capture/ { found = 1 }
|
||||
END { exit !found }
|
||||
'
|
||||
}
|
||||
|
||||
name=""
|
||||
emitted=0
|
||||
|
||||
while IFS= read -r line; do
|
||||
if [[ -n $line && $line != [[:space:]]* ]]; then
|
||||
name="$line"
|
||||
emitted=0
|
||||
elif (( ! emitted )); then
|
||||
device="${line#"${line%%[![:space:]]*}"}"
|
||||
|
||||
if [[ $device == /dev/video* ]] && capture_capable "$device"; then
|
||||
emitted=1
|
||||
printf '%s %s\n' "$device" "$name"
|
||||
fi
|
||||
fi
|
||||
done < <(v4l2-ctl --list-devices 2>/dev/null)
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user