diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
| commit | 28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch) | |
| tree | 85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/webcam | |
| parent | 8470ff001befcfd0f626dea69a9e76d43aee0511 (diff) | |
updates
Diffstat (limited to 'debian/.local/bin/webcam')
| -rwxr-xr-x | debian/.local/bin/webcam | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/debian/.local/bin/webcam b/debian/.local/bin/webcam new file mode 100755 index 0000000..0a4a297 --- /dev/null +++ b/debian/.local/bin/webcam @@ -0,0 +1,48 @@ +#!/bin/sh + +case "$1" in +-h | h | hflip) flip="--vf=lavfi=hflip" ;; +-v | v | vflip) flip="--vf=lavfi=vflip" ;; +-hv | hv | hvflip) flip="--vf=lavfi=hflip,vflip" ;; +*) flip="" ;; +esac + +# Extract full camera names and their first /dev/video* device +cameras=$( + v4l2-ctl --list-devices | awk ' + BEGIN { RS=""; FS="\n" } + { + name = $1; + sub(/ \(.*$/, "", name); + gsub(/^[ \t]+|[ \t]+$/, "", name); + for (i=2; i<=NF; i++) { + if ($i ~ /\/dev\/video/) { + gsub(/^[ \t]+/, "", $i); + print name "|" $i; + break; + } + } + }' +) + +# Extract only camera names for dmenu +names=$(echo "$cameras" | cut -d '|' -f1) + +# Select camera with dmenu +choice=$(echo "$names" | dmenu -i -p 'Choose a camera:') + +# Find corresponding /dev/video* device +camera=$(echo "$cameras" | awk -F '|' -v sel="$choice" '$1 == sel {print $2}') + +# If no selection, exit +[ -z "$camera" ] && exit 1 + +mpv --untimed \ + --no-cache \ + --no-osc \ + --no-input-default-bindings \ + --profile=low-latency \ + --input-conf=/dev/null \ + --title=webcam \ + --x11-name=webcam \ + $flip "$camera" |
