Skip to content

Give speakersafetyd one owner and fix the audio and display checks - #567

Merged
maralcbr merged 3 commits into
quattro-upstreamfrom
mac/74-speakersafetyd-owner
Sep 26, 2026
Merged

maralcbr merged 3 commits into
quattro-upstreamfrom
mac/74-speakersafetyd-owner

Conversation

@maralcbr

Copy link
Copy Markdown
Member

Ticket 74. On image 2 the M2 Max had speakersafetyd preset three times: omarchy-mac's 80-omarchy-mac-audio.preset and omarchy-mac-boot's 80-omarchy-mac.preset (plus 80-omarchy-apple.preset, a link to it), and the boot package's first boot enabled it again. 20260925-4 (84352fd) still did.

What changed

  • omarchy-mac-boot no longer enables speakersafetyd. Its preset drops the line and first boot enables only sddm. omarchy-mac is the single owner.
    • Fresh images still get it: the image builder presets every unit in 80-omarchy-mac*.preset, and its image check refuses an image without the enable link.
    • Upgrades keep it: nothing on the upgrade path reapplies presets, and omarchy-mac's preset keeps it enabled if something does.
  • Audio check (test/manual/apple-audio-check.sh, from Own Apple speaker safety and fix the silent mic mapping in omarchy-mac #535's body). It now reads "Speaker volumes unlocked" from the kernel log, falling back to sudo -n when the user can't read the journal. It used to grep the speakersafetyd unit journal. The owner check counts only enable lines and also requires exactly one enable link.
  • Display check (test/manual/apple-display-check.sh, from ticket 39). From a shell without a seat (SSH), it reruns itself via systemd-run --user --wait --pipe, because logind refuses brightness writes from seatless sessions. --read-only skips the brightness and keyboard steps.

Publish order (for the re-pin)

Edge omarchy-mac 0.1.0-5 is pinned to b4a79d8, before #535, so it ships no speakersafetyd preset. Re-pin and publish omarchy-mac at or past #535 before any omarchy-mac-boot pin that includes this change. Before that:

  • An edge build without the candidate set would have no preset for it, and the image check would fail the build.
  • On an edge-only or mx-mac Mac, a manual systemctl preset-all would drop the link. The upgrade itself keeps it (proof C below).

Optional hardening at the re-pin: make omarchy-mac-boot depend on the owner (a provided name from omarchy-mac's post-#535 recipe). The boot package then can't be installed without the preset.

Tests

  • New packages/omarchy-mac/test/speaker-owner-test.sh, with real systemctl --root on image roots staged from both packages:
    • fresh image: builder presets, the real first-boot hand-off, then the deferred audio step → one link
    • boot package alone → disabled
    • upgrade from the -3/-4 payload, with and without omarchy-mac's setup having run, then preset-all → one link
    • boot upgrade on a Mac with no audio preset → link kept
    • an admin disable survives
  • The boot suite checks its presets leave speakersafetyd disabled and first boot enables only sddm. The new cases fail on the old payload.
  • Suites, run non-root in an Arch Linux ARM container:
    • packages/omarchy-mac/test/all: pass
    • packages/omarchy-mac/boot/test/all: pass
    • ./test/all: 335/336. The one failure is hermes-remove-test.sh, which is on the known-failures list.
  • Real pacman, in a throwaway container: I built omarchy-mac-boot 20260926-1 and omarchy-mac 0.1.0-6 from this branch with the omarchy-pkgs recipes, starting from 20260925-4 on edge.
    • A: M2-like upgrade → enabled, one link, preset owner omarchy-mac only, including after preset-all.
    • B: upgrade with omarchy-mac's setup still queued → same result.
    • C: edge 0.1.0-5 → the upgrade keeps the link; preset-all then disables it (hence the publish order above).
    • D: fresh → one link.
    • E: boot package alone → disabled.
  • M2 Max (read-only, still on omarchy-mac-boot 20260925-3):
    • Audio check with --no-sound: the amps-unlocked check now passes. The owner check fails only because the -3 boot presets are still installed.
    • Display check with --read-only: 0 failures, run over SSH, which exercises the rerun in the session. A probe showed the rerun lands in session 1 on seat0 and keeps the exit code.

Second review: SAFE WITH FIXES. One high finding, fixed: the owner check failed when /etc/systemd/system-preset is missing. One low finding, covered by a new test case: a boot upgrade on a Mac with no owner preset.

omarchy-mac-boot 20260925-3/-4 still enabled speakersafetyd from its image
preset (80-omarchy-mac.preset, and 80-omarchy-apple.preset through the link)
and from the first-boot hand-off, next to omarchy-mac's own preset. The boot
package now enables only its own units and the display manager, so
80-omarchy-mac-audio.preset is the single owner. Images still get it enabled
because the builder applies every 80-omarchy-mac*.preset, and upgrades keep
the existing enable link: nothing on the upgrade path reapplies presets, and
omarchy-mac's preset keeps it enabled if something does.

The new package test builds image roots from both packages with real
systemctl --root: a fresh image through the builder's presets, the real
first-boot hand-off and the deferred audio step ends with one enable link, and
an upgrade from the -3/-4 payload keeps it, with or without omarchy-mac's setup
having run, through preset-all too. The boot suite checks its presets leave
speakersafetyd disabled and that first boot enables only sddm.
The audio check looked for "unlocked" in speakersafetyd's journal, but
snd-soc-macaudio logs "Speaker volumes unlocked" in the kernel log; it now
reads that, through sudo -n when the user cannot read the system journal. The
single-owner check counts only enable lines and also requires one enable link.

brightnessctl goes through logind, which refuses a session without a seat, so
over SSH the display check reruns itself in the user's service manager, which
carries the desktop session. --read-only skips its brightness and keyboard
steps.
grep exits 2 when one of its files is a glob that matched nothing, so the
single-owner check failed on every Mac without /etc/systemd/system-preset.
The owner test also covers a boot upgrade on a Mac whose omarchy-mac has no
speakersafetyd preset yet (edge 0.1.0-5, or mx-mac without omarchy-mac): the
link stays.
@maralcbr
maralcbr merged commit 88c5d18 into quattro-upstream Sep 26, 2026
5 checks passed
maralcbr added a commit to omacom/omarchy-pkgs that referenced this pull request Sep 27, 2026
From omacom/omarchy-mac#567 the add-on enables speakersafetyd itself and its
README says the recipe declares mkinitcpio and the protected speaker stack
(asahi-audio, which pulls speakersafetyd, alsa-ucm-conf-asahi, rtkit,
pipewire-alsa).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant