diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-06-29 15:52:38 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-06-29 15:52:38 +0900 |
| commit | 6d4a3866ff2f5ecb0375d70a0a0d694b066a64df (patch) | |
| tree | 119b64aa9d24317ed8014e999add916d2ee33f60 /ar/.local/bin/dmenurecord | |
| parent | 7bf3f2f31c74385b95f4068c5d7dacff720d7292 (diff) | |
updates
Diffstat (limited to 'ar/.local/bin/dmenurecord')
| -rwxr-xr-x | ar/.local/bin/dmenurecord | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/ar/.local/bin/dmenurecord b/ar/.local/bin/dmenurecord index 4e493c5..037930b 100755 --- a/ar/.local/bin/dmenurecord +++ b/ar/.local/bin/dmenurecord @@ -56,10 +56,34 @@ video() { updateicon "⏺️" } +webcamselect() { + 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; + } + } + }' + ) + names=$(echo "$cameras" | cut -d '|' -f1) + choice=$(echo "$names" | dmenu -i -p 'Choose a camera:') + camera=$(echo "$cameras" | awk -F '|' -v sel="$choice" '$1 == sel {print $2}') +} + webcamhidef() { + [ -z "$camera" ] && exit ffmpeg \ + -display_hflip \ -f v4l2 \ - -i /dev/video0 \ + -i "$camera" \ -video_size 1920x1080 \ "$recordings/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & echo $! >/tmp/recordingpid @@ -67,9 +91,11 @@ webcamhidef() { } webcam() { + [ -z "$camera" ] && exit ffmpeg \ + -display_hflip \ -f v4l2 \ - -i /dev/video0 \ + -i "$camera" \ -video_size 640x480 \ "$recordings/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & echo $! >/tmp/recordingpid @@ -92,8 +118,9 @@ askrecording() { audio) audio ;; video) video ;; *selected) videoselected ;; - webcam) webcam ;; - "webcam (hi-def)") webcamhidef ;; + webcam) webcamselect && webcam ;; + "webcam (hi-def)") webcamselect && webcamhidef ;; + *) exit ;; esac } |
