Files
omarchycn/install/hardware/apple/fix-t2.sh
T
b85ae70ebd Stop pipefail from turning grep -q SIGPIPE exits into false negatives (#6614)
* Stop pipefail from turning grep -q SIGPIPE exits into false negatives

grep -q exits at the first match, and when the producer is still writing
it dies with SIGPIPE. Under pipefail that 141 becomes the pipeline's
status, so hardware checks like lspci | grep -q read as "not found" on
exactly the machines they target. The T2 defaults migration hit this and
silently skipped real T2 Macs (#6608).

Redirect grep to /dev/null instead of -q wherever a pipeline feeds grep
in a pipefail context, so grep reads all input and the producer never
gets killed. The install-time T2 checks aren't run under pipefail today
but are switched too, since they're the same detection line the issue
calls out.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Re-run the T2 defaults migration its broken hardware check skipped

The SIGPIPE bug marked 1785944594 as applied without doing anything on
affected T2 Macs. The original migration is idempotent, so a fresh
migration can just source it now that the guard is fixed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Address Copilot review: fix OCR grep pipeline and prove the T2 repair

screen_contains piped tesseract into grep -Fqi under the acceptance
suite's pipefail, the same SIGPIPE false negative the rest of the branch
fixes. The T2 test's lspci stub now keeps writing past the pipe buffer
after the match so every scenario exercises the SIGPIPE case, and a new
case runs the rerun migration against fixtures a bitten install would
have.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 23:43:49 +02:00

57 lines
1.6 KiB
Bash

# Detect T2 MacBook models using PCI IDs
# Vendor: 106b (Apple), Device IDs: 1801 or 1802 (T2 Security Chip)
if lspci -nn | grep "106b:180[12]" >/dev/null; then
echo "Detected MacBook with T2 chip. Installing support items..."
omarchy-pkg-add \
linux-t2 \
linux-t2-headers \
apple-t2-audio-config \
apple-bcm-firmware \
t2fanrd
# Enable T2 fan control
systemctl enable t2fanrd.service
mkdir -p /etc/modules-load.d
{
echo "t2bce_vhci"
echo "hci_bcm4377"
} > /etc/modules-load.d/t2.conf
# linux-t2 7.1.4 replaced the apple-bce driver with t2bce; t2bce_vhci is the
# virtual USB host controller the internal keyboard hangs off, and mkinitcpio
# pulls t2bce_core/t2bce_dma in via module dependencies.
mkdir -p /etc/mkinitcpio.conf.d
echo "MODULES+=(t2bce_vhci usbhid hid_apple hid_generic xhci_pci xhci_hcd)" > \
/etc/mkinitcpio.conf.d/apple-t2.conf
mkdir -p /etc/modprobe.d
cat > /etc/modprobe.d/brcmfmac.conf <<'EOF'
# Fix for T2 MacBook WiFi connectivity issues
options brcmfmac feature_disable=0x82000
EOF
mkdir -p /etc/limine-entry-tool.d
cat > /etc/limine-entry-tool.d/t2-mac.conf <<'EOF'
# Generated by Omarchy installer for T2 Mac support
KERNEL_CMDLINE[default]+=" intel_iommu=on iommu=pt pm_async=off mem_sleep_default=deep"
EOF
# t2fanrd only reads sections for detected fans, so Fan2 is harmless on
# single-fan models and required on dual-fan MacBooks.
cat > /etc/t2fand.conf <<'EOF'
[Fan1]
low_temp=55
high_temp=75
speed_curve=linear
always_full_speed=false
[Fan2]
low_temp=55
high_temp=75
speed_curve=linear
always_full_speed=false
EOF
fi