Fix screenrecording webcam selector
This commit is contained in:
@@ -17,17 +17,16 @@ webcam_list() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
devices=$(webcam_list)
|
mapfile -t devices < <(webcam_list)
|
||||||
if [[ -z $devices ]]; then
|
if (( ${#devices[@]} == 0 )); then
|
||||||
omarchy-notification-send "No webcam devices found" -u critical -t 3000
|
omarchy-notification-send "No webcam devices found" -u critical -t 3000
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
count=$(grep -c . <<<"$devices")
|
if (( ${#devices[@]} == 1 )); then
|
||||||
if (( count == 1 )); then
|
device="${devices[0]%%[[:space:]]*}"
|
||||||
device="${devices%%[[:space:]]*}"
|
|
||||||
else
|
else
|
||||||
selection=$(omarchy-menu-select "Select Webcam" "$devices") || exit 1
|
selection=$(omarchy-menu-select "Select Webcam" "${devices[@]}" -- --width 520 --maxheight 520) || exit 1
|
||||||
device="${selection%%[[:space:]]*}"
|
device="${selection%%[[:space:]]*}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
source "$(dirname "$0")/base-test.sh"
|
||||||
|
|
||||||
|
tmp_dir=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$tmp_dir"' EXIT
|
||||||
|
|
||||||
|
stub_bin="$tmp_dir/bin"
|
||||||
|
mkdir -p "$stub_bin"
|
||||||
|
|
||||||
|
cat >"$stub_bin/v4l2-ctl" <<'SH'
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
printf '%s\n' "Built-in Webcam: Integrated Camera"
|
||||||
|
printf '\t%s\n' "/dev/video0"
|
||||||
|
printf '\t%s\n' "/dev/video1"
|
||||||
|
printf '\n'
|
||||||
|
printf '%s\n' "USB Capture Card: External Camera"
|
||||||
|
printf '\t%s\n' "/dev/video2"
|
||||||
|
SH
|
||||||
|
|
||||||
|
cat >"$stub_bin/omarchy-menu-select" <<'SH'
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
printf '%s\n' "$@" >"$OMARCHY_TEST_MENU_ARGS"
|
||||||
|
printf '%s\n' "$3"
|
||||||
|
SH
|
||||||
|
|
||||||
|
cat >"$stub_bin/omarchy-capture-screenrecording" <<'SH'
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
printf '%s\n' "$@" >"$OMARCHY_TEST_RECORDER_ARGS"
|
||||||
|
SH
|
||||||
|
|
||||||
|
cat >"$stub_bin/omarchy-notification-send" <<'SH'
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
printf '%s\n' "$@" >"$OMARCHY_TEST_NOTIFICATION_ARGS"
|
||||||
|
SH
|
||||||
|
|
||||||
|
chmod +x "$stub_bin"/*
|
||||||
|
|
||||||
|
export PATH="$stub_bin:$ROOT/bin:$PATH"
|
||||||
|
export OMARCHY_TEST_MENU_ARGS="$tmp_dir/menu-args"
|
||||||
|
export OMARCHY_TEST_RECORDER_ARGS="$tmp_dir/recorder-args"
|
||||||
|
export OMARCHY_TEST_NOTIFICATION_ARGS="$tmp_dir/notification-args"
|
||||||
|
|
||||||
|
"$ROOT/bin/omarchy-capture-screenrecording-with-webcam"
|
||||||
|
|
||||||
|
expected_menu_args="$tmp_dir/expected-menu-args"
|
||||||
|
printf '%s\n' \
|
||||||
|
"Select Webcam" \
|
||||||
|
"/dev/video0 Built-in Webcam: Integrated Camera" \
|
||||||
|
"/dev/video2 USB Capture Card: External Camera" \
|
||||||
|
"--" \
|
||||||
|
"--width" \
|
||||||
|
"520" \
|
||||||
|
"--maxheight" \
|
||||||
|
"520" >"$expected_menu_args"
|
||||||
|
|
||||||
|
if ! cmp -s "$OMARCHY_TEST_MENU_ARGS" "$expected_menu_args"; then
|
||||||
|
fail "screenrecording webcam picker passes each webcam as a menu option" "$(diff -u "$expected_menu_args" "$OMARCHY_TEST_MENU_ARGS")"
|
||||||
|
fi
|
||||||
|
pass "screenrecording webcam picker passes each webcam as a menu option"
|
||||||
|
|
||||||
|
expected_recorder_args="$tmp_dir/expected-recorder-args"
|
||||||
|
printf '%s\n' \
|
||||||
|
"--with-desktop-audio" \
|
||||||
|
"--with-microphone-audio" \
|
||||||
|
"--with-webcam" \
|
||||||
|
"--webcam-device=/dev/video2" >"$expected_recorder_args"
|
||||||
|
|
||||||
|
if ! cmp -s "$OMARCHY_TEST_RECORDER_ARGS" "$expected_recorder_args"; then
|
||||||
|
fail "screenrecording webcam picker starts recording with selected device" "$(diff -u "$expected_recorder_args" "$OMARCHY_TEST_RECORDER_ARGS")"
|
||||||
|
fi
|
||||||
|
pass "screenrecording webcam picker starts recording with selected device"
|
||||||
Reference in New Issue
Block a user