summaryrefslogtreecommitdiff
path: root/ar/.local
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-02-25 14:40:40 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-02-25 14:40:40 +0900
commit81114ca24f85a268a9c747ac27e4d853d9d55726 (patch)
treebad2ae16da9d49c05a48d42f869e468529d4c9b6 /ar/.local
parent93ff825b72b495fc0ccdad07fde11710ffd895bf (diff)
modified mpv/input.conf, modified bin/webcam
Diffstat (limited to 'ar/.local')
-rwxr-xr-xar/.local/bin/webcam33
1 files changed, 32 insertions, 1 deletions
diff --git a/ar/.local/bin/webcam b/ar/.local/bin/webcam
index 8fcb724..7800b46 100755
--- a/ar/.local/bin/webcam
+++ b/ar/.local/bin/webcam
@@ -7,10 +7,41 @@ case "$1" in
*) 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 "$flip" "$(find /dev -name 'video[02468]' 2>/dev/null | tail -n 1)"
+ --title=webcam \
+ $flip "$camera"