Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bin/omarchy-hw-facetimehd
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
1 change: 1 addition & 0 deletions install/hardware/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ run_logged "$OMARCHY_INSTALL/hardware/apple/fix-spi-keyboard.sh"
run_logged "$OMARCHY_INSTALL/hardware/apple/fix-suspend-nvme.sh"
run_logged "$OMARCHY_INSTALL/hardware/apple/fix-t2.sh"
run_logged "$OMARCHY_INSTALL/hardware/apple/fix-brcmfmac-supplicant.sh"
run_logged "$OMARCHY_INSTALL/hardware/apple/fix-facetimehd.sh"

run_logged "$OMARCHY_INSTALL/hardware/lenovo/fix-yoga-pro7-bass-speakers.sh"

Expand Down
19 changes: 19 additions & 0 deletions install/hardware/apple/fix-facetimehd.sh
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
4 changes: 4 additions & 0 deletions install/omarchy-other.packages
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,9 @@ linux-t2
linux-t2-headers
t2fanrd

# FaceTime HD camera on Intel Macs
facetimehd-dkms
facetimehd-firmware-fetcher

# Framework 16
qmk-hid
6 changes: 5 additions & 1 deletion manual/44-mac-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ It is necessary to disable Apple's Secure Boot in order to boot the bootable USB
3. Select the orange EFI Boot device
4. Proceed with the [install as normal](02-getting-started.md)

The installer detects Mac hardware and applies the needed fixes automatically: Broadcom Wi-Fi drivers and firmware, the SPI keyboard driver on the MacBook models that need it, and an NVMe suspend fix for those same models.
The installer detects Mac hardware and applies the needed fixes automatically: Broadcom Wi-Fi drivers and firmware, the FaceTime HD camera driver on machines with a Broadcom 1570 (its firmware is downloaded from Apple during the install, or on the first boot that has a network), the SPI keyboard driver on the MacBook models that need it, and an NVMe suspend fix for those same models.

### Known Limitations

Members of the community are constantly working on solutions to these challenges so if these are problematic for you, join #omarchy-on-other in our [Discord](https://discord.gg/tXFUdasqhY) and see if there's any up-to-date methods for resolving these.

#### FaceTime HD Camera

Close any app using the camera before hibernating. The camera driver is unloaded for hibernation because it hangs the machine otherwise, and it cannot be unloaded while the camera is in use.

#### Devices with T1 Chip

The Apple T1 chip was introduced in late 2016 and used exclusively in the first-generation MacBook Pro models with Touch Bar.
Expand Down
15 changes: 15 additions & 0 deletions migrations/1795284903.sh
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
143 changes: 143 additions & 0 deletions test/shell.d/facetimehd-test.sh
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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Upgrade steps lack tests

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!

Copy link
Copy Markdown
Collaborator

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 a bin/ 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 set reboot-required when 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 what facetimehd-test.sh covers. Checked by Claude Opus 5.5.

Copy link
Copy Markdown
Contributor

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"?


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"