From 2d3d1e2a3ccc3e6c3a29b506712e4f7161c4d8d7 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 23 Jul 2026 16:33:12 -0700 Subject: [PATCH] Only offer webcam recording when available --- bin/omarchy-hw-webcam | 5 +++++ default/omarchy/omarchy-menu.jsonc | 2 +- test/shell.d/menu-test.sh | 5 +++++ test/shell.d/screenrecording-test.sh | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 bin/omarchy-hw-webcam diff --git a/bin/omarchy-hw-webcam b/bin/omarchy-hw-webcam new file mode 100755 index 00000000..4874dd77 --- /dev/null +++ b/bin/omarchy-hw-webcam @@ -0,0 +1,5 @@ +#!/bin/bash + +# omarchy:summary=Check whether a webcam is available + +v4l2-ctl --list-devices 2>/dev/null | grep -q '^[[:space:]]*/dev/video' diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index e73a1d44..76597083 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -54,7 +54,7 @@ "trigger.capture.screenrecord.no-audio": {"icon":"","label":"With no audio","action":"omarchy-capture-screenrecording"}, "trigger.capture.screenrecord.desktop-audio": {"icon":"","label":"With desktop audio","action":"omarchy-capture-screenrecording --with-desktop-audio"}, "trigger.capture.screenrecord.microphone": {"icon":"","label":"With desktop + microphone audio","action":"omarchy-capture-screenrecording --with-desktop-audio --with-microphone-audio"}, - "trigger.capture.screenrecord.webcam": {"icon":"","label":"With desktop + microphone audio + webcam","action":"omarchy-capture-screenrecording-with-webcam"}, + "trigger.capture.screenrecord.webcam": {"icon":"","label":"With desktop + microphone audio + webcam","when":"omarchy-hw-webcam","action":"omarchy-capture-screenrecording-with-webcam"}, "trigger.transcode": {"icon":"󰧸","label":"Transcode","action":"omarchy-transcode"}, "trigger.share": {"icon":"","label":"Share","aliases":["share"]}, "trigger.toggle": {"icon":"󰔎","label":"Toggle","aliases":["toggle","toggles"]}, diff --git a/test/shell.d/menu-test.sh b/test/shell.d/menu-test.sh index 6cc5239e..ba231c32 100644 --- a/test/shell.d/menu-test.sh +++ b/test/shell.d/menu-test.sh @@ -161,6 +161,11 @@ assertEqual( 'omarchy-hw-laptop', 'menu only shows Mirror Display on laptops' ) +assertEqual( + defaultById['trigger.capture.screenrecord.webcam'].when, + 'omarchy-hw-webcam', + 'menu only shows webcam screen recording when a webcam is available' +) assert( /font\.family: row\.iconFont\.length > 0 \? row\.iconFont : root\.fontFamily/.test(menuQml), 'menu rows support per-icon font families' diff --git a/test/shell.d/screenrecording-test.sh b/test/shell.d/screenrecording-test.sh index 2abadec2..238dc28b 100644 --- a/test/shell.d/screenrecording-test.sh +++ b/test/shell.d/screenrecording-test.sh @@ -13,6 +13,8 @@ mkdir -p "$stub_bin" cat >"$stub_bin/v4l2-ctl" <<'SH' #!/bin/bash +[[ ${OMARCHY_TEST_NO_WEBCAM:-false} == "true" ]] && exit 0 + printf '%s\n' "Built-in Webcam: Integrated Camera" printf '\t%s\n' "/dev/video0" printf '\t%s\n' "/dev/video1" @@ -47,6 +49,18 @@ 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" +if "$ROOT/bin/omarchy-hw-webcam"; then + pass "webcam hardware detection succeeds when a video device is available" +else + fail "webcam hardware detection succeeds when a video device is available" +fi + +if OMARCHY_TEST_NO_WEBCAM=true "$ROOT/bin/omarchy-hw-webcam"; then + fail "webcam hardware detection fails when no video device is available" +else + pass "webcam hardware detection fails when no video device is available" +fi + "$ROOT/bin/omarchy-capture-screenrecording-with-webcam" expected_menu_args="$tmp_dir/expected-menu-args"