Repository navigation
Install the FaceTime HD camera driver on Intel Macs that have one #12067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+476
−1
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8bb9e8e
Install the FaceTime HD camera driver on Intel Macs that have one
MrBazzieB a82c4bd
Fetch the FaceTime HD firmware from Apple rather than shipping it
omarchybot b72e735
Say the camera firmware arrives once the Mac is online
omarchybot 442865e
Refuse hibernation while the FaceTime HD camera is in use
omarchybot 38fcf96
Share the driver lock with the fetcher and start the fetch on an imag…
omarchybot 39be195
Mark every hibernating sleep in progress, not only one that unloaded …
omarchybot 7854932
Resume the fetcher's activation on wake instead of loading for it
omarchybot e929c33
Check the camera came back after the sleep, not only that the driver …
omarchybot aa8c505
Keep the wake step within the sleep unit's stop budget
omarchybot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
|
|
||
| # omarchy:summary=Detect a Broadcom FaceTime HD PCIe webcam (14e4:1570). | ||
|
|
||
| # grep -q would SIGPIPE a chatty lspci under pipefail and look like "no camera". | ||
| lspci -nn | grep "14e4:1570" >/dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Broadcom 720p FaceTime HD (PCI 14e4:1570) on Intel Macs. There is no in-tree driver, and Apple's license forbids | ||
| # redistributing the camera's firmware, so facetimehd-firmware-fetcher downloads it from Apple on the Mac itself. | ||
|
|
||
| if omarchy-hw-facetimehd; then | ||
| echo "Detected FaceTime HD camera" | ||
|
|
||
| # pacman -T resolves provides, so a Mac already running an AUR driver or firmware keeps it rather than conflicting. | ||
| packages=() | ||
| pacman -T facetimehd-dkms >/dev/null || pacman -T bcwc-pcie >/dev/null || | ||
| pacman -T bcwc-pcie-dkms >/dev/null || packages+=(facetimehd-dkms) | ||
| pacman -T facetimehd-firmware >/dev/null || pacman -T facetimehd-data >/dev/null || | ||
| pacman -T bcwc-pcie-firmware >/dev/null || packages+=(facetimehd-firmware-fetcher) | ||
| (( ${#packages[@]} == 0 )) || omarchy-pkg-add "${packages[@]}" | ||
|
|
||
| # An install with no network fetches on the first boot that has one. | ||
| if pacman -Q facetimehd-firmware-fetcher &>/dev/null; then | ||
| sudo systemctl enable facetimehd-firmware-fetcher.service | ||
| fi | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| echo "Install the FaceTime HD camera driver on Intel Macs that have one" | ||
|
|
||
| # Fresh installs get this from install/hardware/apple/fix-facetimehd.sh. Existing | ||
| # Macs only pick it up on omarchy update via this migration. | ||
| if omarchy-hw-facetimehd; then | ||
| source "$OMARCHY_PATH/install/hardware/apple/fix-facetimehd.sh" | ||
|
|
||
| # The module only loads at boot, so the camera stays missing until then. | ||
| (( ${#packages[@]} == 0 )) || omarchy-state set reboot-required | ||
|
|
||
| # The leaf only enables the fetch for the next boot; on a running system it can start now. | ||
| if pacman -Q facetimehd-firmware-fetcher &>/dev/null; then | ||
| sudo systemctl start --no-block facetimehd-firmware-fetcher.service | ||
| fi | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| leaf="$ROOT/install/hardware/apple/fix-facetimehd.sh" | ||
| hw="$ROOT/bin/omarchy-hw-facetimehd" | ||
| all="$ROOT/install/hardware/all.sh" | ||
| manual="$ROOT/manual/44-mac-support.md" | ||
| other_packages="$ROOT/install/omarchy-other.packages" | ||
|
|
||
| grep -q 'apple/fix-facetimehd.sh' "$all" || | ||
| fail "the FaceTime HD fix runs during hardware setup" | ||
| grep -q 'omarchy-hw-facetimehd' "$leaf" || | ||
| fail "the install leaf keys off the FaceTime HD detector" | ||
| grep -q 'facetimehd-dkms' "$leaf" || | ||
| fail "the install leaf installs facetimehd-dkms" | ||
| grep -qx 'facetimehd-dkms' "$other_packages" || | ||
| fail "the ISO caches facetimehd-dkms" | ||
| grep -qx 'facetimehd-firmware-fetcher' "$other_packages" || | ||
| fail "the ISO caches facetimehd-firmware-fetcher" | ||
| ! grep -qxE 'facetimehd-(firmware|data)' "$other_packages" || | ||
| fail "the ISO carries no Apple firmware, which may not be redistributed" | ||
| grep -q '14e4:1570' "$hw" || | ||
| fail "the detector matches the Broadcom 1570 PCI ID" | ||
| grep -q 'FaceTime HD' "$manual" || | ||
| fail "Mac support documents the FaceTime HD camera" | ||
| pass "the FaceTime HD fix is wired into hardware setup" | ||
|
|
||
| test_tmp=$(mktemp -d) | ||
| trap 'rm -rf "$test_tmp"' EXIT | ||
|
|
||
| stub_bin="$test_tmp/bin" | ||
| calls="$test_tmp/calls.log" | ||
| mkdir -p "$stub_bin" | ||
| : >"$calls" | ||
|
|
||
| cat >"$stub_bin/lspci" <<'SH' | ||
| #!/bin/bash | ||
|
|
||
| # Chatty like real lspci: keep writing well past the pipe buffer after the | ||
| # match, so a grep -q consumer would kill this stub with SIGPIPE and pipefail | ||
| # would read that as "no such hardware" (#6608). | ||
| if (( ${FACETIMEHD_HARDWARE:-0} == 1 )); then | ||
| echo '02:00.0 Multimedia controller [0480]: Broadcom Inc. 720p FaceTime HD Camera [14e4:1570]' | ||
| fi | ||
| for _ in {1..4096}; do | ||
| echo '00:00.0 Host bridge [0600]: Filler Device [ffff:0000]' | ||
| done | ||
| SH | ||
|
|
||
| cat >"$stub_bin/omarchy-pkg-add" <<'SH' | ||
| #!/bin/bash | ||
|
|
||
| printf 'omarchy-pkg-add' >>"$TEST_LOG" | ||
| printf '\t%s' "$@" >>"$TEST_LOG" | ||
| printf '\n' >>"$TEST_LOG" | ||
| printf '%s\n' "$@" >>"$TEST_INSTALLED" | ||
| SH | ||
|
|
||
| # -T answers for what is installed or named in FACETIMEHD_PROVIDED, as an AUR package providing it would be. | ||
| cat >"$stub_bin/pacman" <<'SH' | ||
| #!/bin/bash | ||
|
|
||
| satisfied() { | ||
| grep -qxF -- "$1" "$TEST_INSTALLED" || [[ " ${FACETIMEHD_PROVIDED:-} " == *" $1 "* ]] | ||
| } | ||
|
|
||
| case "$1" in | ||
| -T) for dep in "${@:2}"; do satisfied "$dep" || { echo "$dep"; exit 127; }; done ;; | ||
| -Q) grep -qxF -- "$2" "$TEST_INSTALLED" ;; | ||
| *) exit 2 ;; | ||
| esac | ||
| SH | ||
|
|
||
| cat >"$stub_bin/systemctl" <<'SH' | ||
| #!/bin/bash | ||
|
|
||
| printf 'systemctl' >>"$TEST_LOG" | ||
| printf '\t%s' "$@" >>"$TEST_LOG" | ||
| printf '\n' >>"$TEST_LOG" | ||
| SH | ||
|
|
||
| cat >"$stub_bin/sudo" <<'SH' | ||
| #!/bin/bash | ||
|
|
||
| printf 'sudo' >>"$TEST_LOG" | ||
| printf '\t%s' "$@" >>"$TEST_LOG" | ||
| printf '\n' >>"$TEST_LOG" | ||
| "$@" | ||
| SH | ||
|
|
||
| install -m0755 "$hw" "$stub_bin/omarchy-hw-facetimehd" | ||
| chmod +x "$stub_bin"/* | ||
|
|
||
| # Detector: present | ||
| FACETIMEHD_HARDWARE=1 PATH="$stub_bin:$PATH" "$stub_bin/omarchy-hw-facetimehd" | ||
| pass "detector matches PCI 14e4:1570" | ||
|
|
||
| # Detector: absent | ||
| if FACETIMEHD_HARDWARE=0 PATH="$stub_bin:$PATH" "$stub_bin/omarchy-hw-facetimehd"; then | ||
| fail "detector ignores machines without a FaceTime HD camera" | ||
| fi | ||
| pass "detector skips machines without a FaceTime HD camera" | ||
|
|
||
| installed="$test_tmp/installed" | ||
|
|
||
| run_leaf() { | ||
| local hardware="$1" provided="${2:-}" | ||
| : >"$calls" | ||
| : >"$installed" | ||
| FACETIMEHD_HARDWARE="$hardware" FACETIMEHD_PROVIDED="$provided" PATH="$stub_bin:$PATH" TEST_LOG="$calls" \ | ||
| TEST_INSTALLED="$installed" bash -euo pipefail -c 'source "$1"' _ "$leaf" | ||
| } | ||
|
|
||
| fetcher_enabled=$'systemctl\tenable\tfacetimehd-firmware-fetcher.service' | ||
|
|
||
| run_leaf 1 | ||
| grep -Fxq $'omarchy-pkg-add\tfacetimehd-dkms\tfacetimehd-firmware-fetcher' "$calls" || | ||
| fail "leaf installs the DKMS module and the firmware fetcher" "$(cat "$calls")" | ||
| grep -Fxq "$fetcher_enabled" "$calls" || | ||
| fail "leaf enables the fetch for a first boot with a network" "$(cat "$calls")" | ||
| pass "leaf installs the DKMS module and the firmware fetcher, and enables the fetch" | ||
|
|
||
| run_leaf 1 facetimehd-dkms | ||
| grep -Fxq $'omarchy-pkg-add\tfacetimehd-firmware-fetcher' "$calls" || | ||
| fail "leaf keeps a driver the AUR already provides" "$(cat "$calls")" | ||
| pass "leaf keeps a driver the AUR already provides" | ||
|
|
||
| run_leaf 1 bcwc-pcie | ||
| grep -Fxq $'omarchy-pkg-add\tfacetimehd-firmware-fetcher' "$calls" || | ||
| fail "leaf keeps the legacy bcwc-pcie driver" "$(cat "$calls")" | ||
| pass "leaf keeps the legacy bcwc-pcie driver" | ||
|
|
||
| run_leaf 1 "facetimehd-dkms facetimehd-data" | ||
| ! grep -q -e omarchy-pkg-add -e systemctl "$calls" || | ||
| fail "leaf installs nothing where the driver and firmware are already provided" "$(cat "$calls")" | ||
| pass "leaf installs nothing where the driver and firmware are already provided" | ||
|
|
||
| run_leaf 0 | ||
| [[ ! -s $calls ]] || fail "non-matching hardware is a no-op" "$(cat "$calls")" | ||
| pass "leaf is a no-op on machines without a FaceTime HD camera" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests run the install leaf but never run
migrations/1795284903.sh. They miss the reboot flag and service start that existing installs depend on, so those steps can break while the tests still pass. Add migration cases for matching hardware, already-installed packages, unmatched hardware, and package-install failure. Check the reboot flag and service-start calls.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not changed. Omarchy's migration guide says not to add tests for a migration under
test/(agents/skills/migrations.md: "It runs once per machine and is frozen once it ships, so the test stops guarding anything. If a migration needs logic worth testing, put that logic in abin/command the migration calls and test the command"), and the migration's checks were removed from this test for that reason. What it does beyond the leaf is setreboot-requiredwhen the leaf selected packages and start the fetch; both were exercised on a disposable Omarchy VM against real pacman, where the migration installed both packages, set the flag and started the service, which fetched the firmware. The leaf it sources, which holds the logic, is whatfacetimehd-test.shcovers. Checked by Claude Opus 5.5.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it — that makes sense. I wasn't aware of Omarchy's migration testing policy. If the migration sources a tested leaf and the one-time orchestration (flag + service start) was verified manually on a real system, that aligns with the project's approach of not adding tests for frozen, single-run migration scripts.
Based on your explanation, shall I remember this as a rule: "Do not flag missing tests for migrations under
test/; Omarchy's policy is to test reusable logic (bin/ commands, install leaves) separately and verify the migration orchestration manually on real systems, since migrations run once per machine and are frozen after shipping"?