Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions bin/omarchy-hw-apple-t1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# omarchy:summary=Detect whether the computer is a T1 Touch Bar MacBook Pro
# omarchy:hidden=true

# T1 lives only in the first-generation Touch Bar MacBook Pros (2016–2017).
# 13,1 and 14,1 are the two-port 13" models and have no Touch Bar.
product_name=$(cat "${OMARCHY_DMI_PRODUCT_NAME:-/sys/class/dmi/id/product_name}" 2>/dev/null)
[[ $product_name =~ MacBookPro13,[23]|MacBookPro14,[23] ]]
20 changes: 20 additions & 0 deletions bin/omarchy-hw-apple-t1-bind
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# omarchy:summary=Rebind T1 iBridge HID interfaces to apple-ibridge
# omarchy:hidden=true

# hid-generic is built in and claims 05ac:8600 before the out-of-tree
# apple-ibridge driver loads. The udev rule runs this once apple_ib_tb appears.
hid_root=${OMARCHY_T1_HID_ROOT:-/sys/bus/hid}

for d in "$hid_root"/devices/0003:05AC:8600.*; do
[[ -d $d ]] || continue
name=$(basename "$d")
drv=""
if [[ -e $d/driver ]]; then
drv=$(basename "$(readlink -f "$d/driver")")
fi
[[ $drv == "apple-ibridge-hid" ]] && continue
[[ -n $drv ]] && echo -n "$name" >"$hid_root/drivers/$drv/unbind"
echo -n "$name" >"$hid_root/drivers/apple-ibridge-hid/bind"
done
78 changes: 78 additions & 0 deletions bin/omarchy-setup-apple-touchbar
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash

# omarchy:summary=Install T1 Touch Bar firmware from a USB stick onto the EFI partition
# omarchy:requires-sudo=true

set -euo pipefail

if (( $(id -u) != 0 )); then
echo "Need root to write the EFI System Partition and udev rules."
exec sudo --preserve-env=OMARCHY_PATH /bin/bash "$0" "$@"
fi

OMARCHY_PATH=${OMARCHY_PATH:-/usr/share/omarchy}
# shellcheck source=../../install/hardware/apple/t1-touchbar.sh
source "$OMARCHY_PATH/install/hardware/apple/t1-touchbar.sh"

if ! omarchy-hw-apple-t1; then
echo "This machine is not a T1 Touch Bar MacBook Pro (MacBookPro13,2/13,3 or 14,2/14,3)."
exit 1
fi

echo "T1 Touch Bar setup"
echo

t1_install_wiring
echo "Installed apple-ib-tb udev rule and module load list."

if t1_firmware_present; then
echo "EFI already has APPLE/EMBEDDEDOS/combined.memboot."
echo "Reboot if the Touch Bar is still dark so Apple's firmware can memboot the T1."
exit 0
fi

if src=$(t1_find_firmware); then
echo "Found firmware: $src"
esp=$(t1_esp_mount) || {
echo "No mounted VFAT EFI System Partition found (/boot, /boot/efi, or /efi)."
exit 1
}
echo "Copying to $esp/EFI/APPLE"
if ! t1_copy_firmware "$src" "$esp"; then
echo "Found T1 firmware but could not copy it to the EFI partition."
echo "Wiring is installed; later run: omarchy setup apple touchbar"
exit 1
fi
echo
echo "OK. Reboot so Apple's EFI can memboot the T1:"
echo " sudo reboot"
exit 0
fi

# USB is present but has no firmware: drop the macOS collector onto it.
wrote=""
while IFS= read -r vol; do
t1_write_collector "$vol"
wrote=$vol
break
done < <(t1_media_roots)

if [[ -n $wrote ]]; then
echo "No APPLE/EMBEDDEDOS on the USB yet."
echo "Wrote copy-t1-firmware.command to:"
echo " $wrote"
echo
echo "Boot this Mac into macOS, wait until the Touch Bar lights up,"
echo "double-click that script in Finder, then come back here and re-run:"
echo " omarchy setup apple touchbar"
exit 0
fi

echo "Plug in the USB that ran copy-t1-firmware.command on macOS,"
echo "wait for it to mount, then re-run:"
echo " omarchy setup apple touchbar"
echo
echo "To collect firmware on macOS first, copy this file onto a stick and"
echo "double-click it in Finder after the Touch Bar is on:"
echo " $(t1_collector_path)"
exit 1
1 change: 1 addition & 0 deletions default/omarchy/omarchy-menu.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"setup.config.hyprsunset": {"icon":"","label":"Hyprsunset","action":"omarchy-launch-config-editor ~/.config/hypr/hyprsunset.conf && omarchy-restart-hyprsunset"},
"setup.config.xcompose": {"icon":"󰞅","label":"XCompose","action":"omarchy-launch-config-editor ~/.XCompose && omarchy-restart-xcompose"},
"setup.direct-boot": {"icon":"","label":"Direct Boot","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-direct-boot"},
"setup.apple-touchbar": {"icon":"󰌌","label":"Touch Bar Firmware","when":"omarchy-hw-apple-t1","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-apple-touchbar"},
"setup.reset": {"icon":"󰑓","label":"Reset Computer","when":"[[ $(findmnt -no FSTYPE /) == btrfs ]]","action":"omarchy-launch-floating-terminal-with-presentation omarchy-system-factory-reset"},

// Install
Expand Down
3 changes: 3 additions & 0 deletions default/udev/apple-t1-touchbar.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# apple-ib-tb is out of tree, so hid-generic (builtin) claims 05ac:8600 first.
# Rebind once the T1 Touch Bar driver is actually loaded.
ACTION=="add", SUBSYSTEM=="module", KERNEL=="apple_ib_tb", RUN+="/usr/bin/omarchy-hw-apple-t1-bind"
1 change: 1 addition & 0 deletions install/hardware/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ run_logged "$OMARCHY_INSTALL/hardware/asus/fix-z13-touchpad.sh"
run_logged "$OMARCHY_INSTALL/hardware/framework/qmk-hid.sh"

run_logged "$OMARCHY_INSTALL/hardware/apple/fix-spi-keyboard.sh"
run_logged "$OMARCHY_INSTALL/hardware/apple/fix-t1-touchbar.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"
Expand Down
180 changes: 180 additions & 0 deletions install/hardware/apple/copy-t1-firmware.command
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#!/bin/bash
# Copy this Mac's T1 Touch Bar firmware (EFI/APPLE) to an external USB.
# Run ON THIS Mac, in macOS, AFTER first boot when the Touch Bar is on.
# Double-click in Finder or: bash copy-t1-firmware.command
#
# Compatible with stock /bin/bash 3.2 (High Sierra through Sequoia).
# Do not "modernize" this file for bash 5; it has to run on macOS.

set -e

need_root() {
if [ "$(id -u)" -ne 0 ]; then
echo "This needs admin to mount the EFI partition."
exec sudo /bin/bash "$0" "$@"
fi
}

is_efi_slice() {
_info=$(diskutil info "$1" 2>/dev/null) || return 1
echo "$_info" | grep -q "Partition Type: *EFI" && return 0
echo "$_info" | grep -q "Content: *EFI" && return 0
echo "$_info" | grep -q "Volume Name: *EFI" && return 0
return 1
}

mount_efi() {
_dev="$1"
_out=$(diskutil mount "$_dev" 2>&1) || {
echo "Could not mount $_dev:"
echo "$_out"
return 1
}
_mp=$(diskutil info "$_dev" | awk -F': *' '/Mount Point:/ {print $2; exit}')
if [ -z "$_mp" ] || [ "$_mp" = "Not applicable" ]; then
echo "$_dev has no mount point"
return 1
fi
echo "$_mp"
}

is_external_vol() {
_vol="$1"
_info=$(diskutil info "$_vol" 2>/dev/null) || return 1
echo "$_info" | grep -qi "Internal: *Yes" && return 1
echo "$_info" | grep -qiE "Protocol: *USB|Device Location: *External|Removable Media: *Removable|Internal: *No"
}

list_efi_devs() {
diskutil list | awk '/disk[0-9]+s[0-9]+$/ {print $NF}' | while read -r _id; do
is_efi_slice "$_id" && echo "$_id"
done
}

list_usb_vols() {
for _v in /Volumes/*; do
[ -d "$_v" ] || continue
_base=$(basename "$_v")
case "$_base" in
EFI|Macintosh\ HD|Macintosh\ HD\ -\ Data|Recovery|com.apple.recovery.boot) continue ;;
esac
is_external_vol "$_v" && echo "$_v"
done
}

find_apple_tree() {
_root="$1"
if [ -f "$_root/EFI/APPLE/EMBEDDEDOS/combined.memboot" ]; then
echo "$_root/EFI/APPLE"
return 0
fi
if [ -f "$_root/APPLE/EMBEDDEDOS/combined.memboot" ]; then
echo "$_root/APPLE"
return 0
fi
return 1
}

echo "T1 Touch Bar firmware copy"
echo "Only copies firmware THIS Mac already wrote to its EFI partition."
echo

need_root "$@"

echo "Looking for EFI/APPLE/EMBEDDEDOS/combined.memboot ..."
echo "(If macOS just finished installing, wait until the Touch Bar lights up, then re-run.)"
echo

SRC=""

for dev in $(list_efi_devs); do
echo "Checking $dev ..."
mp=$(mount_efi "$dev") || continue
apple=$(find_apple_tree "$mp" || true)
if [ -n "$apple" ]; then
SRC="$apple"
echo "Found: $SRC"
ls -la "$SRC/EMBEDDEDOS" || ls -la "$SRC"
break
fi
echo " no EMBEDDEDOS on $dev"
done

if [ -z "$SRC" ]; then
echo
echo "No combined.memboot on any EFI partition yet."
echo "Boot this Mac into macOS until the Touch Bar works, stay on Wi-Fi,"
echo "wait out any 'critical software update', then run this again."
exit 1
fi

echo
echo "External volumes:"
USB_LIST=$(list_usb_vols || true)
if [ -z "$USB_LIST" ]; then
echo " (none found)"
echo
echo "Plug in a USB stick, wait for it to appear in Finder, then re-run."
echo "FAT32, ExFAT, or APFS is fine. Do not pick the EFI partition."
exit 1
fi

OLDIFS=$IFS
IFS='
'
set -- $USB_LIST
IFS=$OLDIFS
n=$#
i=1
for vol; do
echo " $i) $vol"
i=$((i + 1))
done

DEST=""
if [ "$n" -eq 1 ]; then
DEST="$1"
echo
echo "Using the only external volume: $DEST"
else
echo
printf "Number of the USB to copy onto: "
read -r choice
case "$choice" in
''|*[!0-9]*) echo "Not a number."; exit 1 ;;
esac
if [ "$choice" -lt 1 ] || [ "$choice" -gt "$n" ]; then
echo "Out of range."
exit 1
fi
eval DEST=\$$choice
fi

if [ ! -d "$DEST" ]; then
echo "Destination vanished: $DEST"
exit 1
fi

TARGET="$DEST/APPLE"
echo
echo "Copying:"
echo " $SRC"
echo " -> $TARGET"
rm -rf "$TARGET"
mkdir -p "$DEST"
cp -R "$SRC" "$TARGET"

if [ ! -f "$TARGET/EMBEDDEDOS/combined.memboot" ]; then
echo "Copy finished but combined.memboot is missing. Source was incomplete."
exit 1
fi

echo
echo "OK. On the USB:"
ls -la "$TARGET/EMBEDDEDOS"

echo
echo "Eject the USB in Finder before unplugging."
echo "On Omarchy later:"
echo " omarchy setup apple touchbar"
echo "then reboot so Apple's EFI can memboot the T1."
25 changes: 25 additions & 0 deletions install/hardware/apple/fix-t1-touchbar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Detect first-generation Touch Bar MacBook Pros (T1) and install the
# wiring the bar needs. Firmware is machine-specific and is not shipped;
# copy it from a USB that ran copy-t1-firmware.command on macOS.

if omarchy-hw-apple-t1; then
echo "Detected MacBook with T1 Touch Bar"

omarchy-pkg-add linux-headers

# shellcheck source=t1-touchbar.sh
source "$OMARCHY_INSTALL/hardware/apple/t1-touchbar.sh"

t1_install_wiring

if src=$(t1_find_firmware); then
if esp=$(t1_esp_mount) && t1_copy_firmware "$src" "$esp"; then
echo "Installed T1 Touch Bar firmware on the EFI partition"
else
echo "Found T1 firmware on USB but could not copy it to the EFI partition"
fi
else
echo "No T1 firmware on a mounted USB. After install, plug in the stick from"
echo "macOS and run: omarchy setup apple touchbar"
fi
fi
Loading