Skip to content
Merged
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
16 changes: 16 additions & 0 deletions bin/omarchy-hw-fingerprint
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
fingerprint_vendors=" 27c6 138a 06cb 08ff 1c7a 147e "
usb_devices_path="${OMARCHY_USB_DEVICES_PATH:-/sys/bus/usb/devices}"

# A reader the kernel drives without USB (a Mac's Touch ID, behind its Secure
# Enclave) is the platform's to name: each line of its fingerprint-readers file
# is a file (a shell glob) and the value that file reads once the reader is
# usable (see docs/file-layout.md).
platform_readers=/usr/share/omarchy-platform/fingerprint-readers
if [[ -r $platform_readers ]]; then
while IFS=$' \t\r' read -r reader_glob reader_value extra || [[ -n $reader_glob ]]; do
[[ $reader_glob == /* && -n $reader_value && -z $extra ]] || continue
for reader_file in $reader_glob; do
if [[ -r $reader_file && $(<"$reader_file") == "$reader_value" ]]; then
exit 0
fi
done
done <"$platform_readers"
fi

# libfprint drives every reader it supports from userspace over libusb, so a
# real reader sits there with no kernel driver bound to any of its interfaces.
# The other things these vendors build — Synaptics webcam bridges (usbio-bridge
Expand Down
7 changes: 7 additions & 0 deletions docs/file-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ A platform's runtime package (omarchy-mac on Apple Silicon, say) adds its deskto
display-cutouts.json camera cutouts the top bar keeps out of (see omarchy-shell.md)
keyrings signing keyring packages of the repositories the platform adds, one per line
audio.json audio processing nodes the audio panel and microphone widget leave out (below)
fingerprint-readers readers the kernel drives without USB, and the file that shows each one is usable (below)
```

See [lifecycle-dispatch.md](lifecycle-dispatch.md#platform-files).
Expand All @@ -173,6 +174,12 @@ See [lifecycle-dispatch.md](lifecycle-dispatch.md#platform-files).

No environment variable moves the file: these commands also run under `sudo` and from the brightness keys. Their tests (`test/shell.d/hw-display-test.sh`, `test/shell.d/brightness-display-test.sh`) run a copy rewritten to read a fixture in its place.

#### Fingerprint readers (`fingerprint-readers`)

`omarchy-hw-fingerprint` finds USB readers by their product string or vendor. A reader the kernel drives some other way (a Mac's Touch ID sensor, behind its Secure Enclave) is named by the platform package in `/usr/share/omarchy-platform/fingerprint-readers`; Omarchy ships none. Each line is an absolute path, a shell glob, then the value that file reads once the reader is usable; the reader is present when any file the glob matches reads that value. The value must be the file's whole content, not part of it (Touch ID reads `not-ready` before it reads `ready`). Three details decide a match: the file's trailing newlines are dropped before comparing (sysfs ends every value with one), fields are split on whitespace (so neither the glob nor the value can contain a space), and the file is read as the user running the check, the session user, so it must be readable by that user and not only by root. Blank lines, whole-line `#` comments, relative paths and lines with a missing or extra word are ignored. A platform file never hides a USB reader: when no platform-named file matches, the USB scan still runs. On Apple Silicon, omarchy-mac names `/sys/bus/platform/drivers/apple_sep/*/diag/touchid ready`. That file is `0444 root:root`, so the session user can read it. The line follows the kernel's names for the Secure Enclave driver (`apple_sep`) and its `diag/touchid` attribute: if a kernel renames either, the reader and the first-run invitation quietly stop appearing, so the platform package changes the line along with its kernel.

The rest of the fingerprint path is the same for every reader: the setup's first-run invitation follows `omarchy-hw-fingerprint`, so it reaches a machine once its platform's reader is usable, and `omarchy-setup-security-fingerprint` installs `libfprint-git`. Setup can only enroll a platform's reader once that package carries its driver; for a Mac's Touch ID that is the aarch64 build from omacom/omarchy-pkgs#806. `test/shell.d/hw-fingerprint-test.sh` runs a copy rewritten to read a fixture in place of the file.

#### Audio hints (`audio.json`)

The audio panel lists every output, input and playback stream PipeWire has, and the microphone widget counts every recording as the microphone in use (the shell's own level meters never count). A platform whose audio runs through its own processing (DSP filter graphs in front of raw devices, say) has nodes that are neither devices nor apps, and its platform package names them in `/usr/share/omarchy-platform/audio.json`; Omarchy ships none, and without it nothing is left out.
Expand Down
2 changes: 1 addition & 1 deletion docs/lifecycle-dispatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Omarchy has no disk recovery key: the disk, the login user and root share one pa

## Platform files

A platform's runtime package describes its hardware in files under the platform root, `/usr/share/omarchy-platform/`, without an operation and without a branch in Omarchy's code: display hints, camera cutouts, audio nodes, keyrings and key names (see [file-layout.md](file-layout.md#platform-root)). Only the one installed platform package owns the root, and Omarchy ships nothing in it. The root is fixed: no environment variable moves it, and a development checkout in `OMARCHY_PATH` doesn't replace it. A missing root or file means no platform additions. It changes no binds, settings or gestures: Omarchy behaves the same on every machine.
A platform's runtime package describes its hardware in files under the platform root, `/usr/share/omarchy-platform/`, without an operation and without a branch in Omarchy's code: display hints, camera cutouts, audio nodes, keyrings, key names and fingerprint readers (see [file-layout.md](file-layout.md#platform-root)). Only the one installed platform package owns the root, and Omarchy ships nothing in it. The root is fixed: no environment variable moves it, and a development checkout in `OMARCHY_PATH` doesn't replace it. A missing root or file means no platform additions. It changes no binds, settings or gestures: Omarchy behaves the same on every machine.

- **Key names: `key-names`**, one `<keysym> <name>` per line, which the keybindings menu shows in place of the keysym (a MacBook's `XF86MonBrightnessUp` is its F2 key). Its tests run copies of the menu that read a fixture root (`platform_root_copy` in `base-test.sh`).

Expand Down
60 changes: 59 additions & 1 deletion test/shell.d/hw-fingerprint-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ write_usb_devices() {
done
}

# A copy of the command reads its platform file from a fixture root: none
# unless a case writes one, whatever the machine running the suite has installed.
platform_root="$tmp_dir/platform"
mkdir -p "$platform_root" "$tmp_dir/bin"
platform_root_copy "$ROOT/bin/omarchy-hw-fingerprint" "$tmp_dir/bin/omarchy-hw-fingerprint" "$platform_root"

hw_fingerprint() {
OMARCHY_USB_DEVICES_PATH="$tmp_dir/devices" "$ROOT/bin/omarchy-hw-fingerprint"
OMARCHY_USB_DEVICES_PATH="$tmp_dir/devices" "$tmp_dir/bin/omarchy-hw-fingerprint"
}

assert_detects() {
Expand Down Expand Up @@ -103,3 +109,55 @@ assert_detects "a self-named reader is detected with a driver bound"

write_usb_devices '1234:5678:Generic USB Device'
assert_rejects "a machine with no matching USB devices detects nothing"

# A reader the platform names: a file and the value it reads once usable, as a
# Mac's Secure Enclave reports Touch ID. No USB device takes part.
write_platform_readers() {
printf '%s\n' "$@" >"$platform_root/fingerprint-readers"
}
write_sep() {
mkdir -p "$tmp_dir/sep/$1.sep/diag"
printf '%s\n' "$2" >"$tmp_dir/sep/$1.sep/diag/touchid"
}
write_usb_devices '1234:5678:Generic USB Device'
rm -rf "$tmp_dir/sep"
write_sep 396400000 ready
write_platform_readers '# Touch ID' '' "$tmp_dir/sep/*.sep/diag/touchid ready"
assert_detects "a reader the platform names is detected once its file reads the value"

# The kernel's other diag/touchid values: not-ready contains ready, so only a
# whole-value match keeps it from counting.
for value in not-ready unknown failed; do
write_sep 396400000 "$value"
assert_rejects "a reader the platform names is not detected while its file reads $value"
done

write_sep 196400000 ready
assert_detects "any file the platform's glob matches can show the reader"

rm -rf "$tmp_dir/sep"
assert_rejects "a reader whose file is missing is not detected"

write_sep 396400000 ready
printf '%s ready\r\n' "$tmp_dir/sep/*.sep/diag/touchid" >"$platform_root/fingerprint-readers"
assert_detects "a fingerprint-readers file saved with CRLF line ends reads the same"

write_platform_readers "sep/*.sep/diag/touchid ready" "$tmp_dir/sep/*.sep/diag/touchid" \
"$tmp_dir/sep/*.sep/diag/touchid ready now" "#$tmp_dir/sep/*.sep/diag/touchid ready"
assert_rejects "relative paths, a missing value, an extra word and comments name no reader"

# A platform file that matches nothing never hides a USB reader on the same
# machine: the USB scan still runs after it.
write_usb_devices '1234:5678:Goodix Fingerprint USB Device'
write_sep 396400000 not-ready
write_platform_readers "$tmp_dir/sep/*.sep/diag/touchid ready"
assert_detects "a USB reader is detected while the platform's reader is not ready"
write_platform_readers "$tmp_dir/nowhere/*/diag/touchid ready"
assert_detects "a USB reader is detected while the platform's glob matches nothing"
write_usb_devices '27c6:1234'
assert_detects "a USB reader found by vendor is detected beside a platform file"
write_platform_readers "$tmp_dir/sep/*.sep/diag/touchid ready"
write_sep 396400000 not-ready
assert_detects "a USB reader found by vendor is detected while Touch ID reads not-ready"

rm -f "$platform_root/fingerprint-readers"