Skip to content

Touch Bar mini app: Now Playing (spectrum, track, transport buttons) - #337

Open
DataKnox wants to merge 3 commits into
omacom:quattrofrom
DataKnox:touchbar-now-playing
Open

Touch Bar mini app: Now Playing (spectrum, track, transport buttons)#337
DataKnox wants to merge 3 commits into
omacom:quattrofrom
DataKnox:touchbar-now-playing

Conversation

@DataKnox

@DataKnox DataKnox commented Sep 4, 2026

Copy link
Copy Markdown

What

A first Touch Bar mini app for Touch Bar MacBook Pros: a live audio spectrum, the current track with album art, and previous / play-pause / next buttons drawn straight onto the Touch Bar. Super + Ctrl + M toggles it; tapping F1–F12 at the right end of the bar hands the function keys back.

Track info comes from the shell's media service (omarchy-shell media status), so it works for the Spotify web app this fork uses, and equally for cliamp, mpv, or a browser tab. The spectrum comes from cava listening to PipeWire. Colours follow the active theme.

How it fits

tiny-dfr owns the Touch Bar's DRM device and digitizer, both root-only. The app borrows them through omarchy-touchbar-handoff, a small root helper:

  • app stops tiny-dfr, grants the calling user an ACL on the bar's DRM node and digitizer, and makes the user the owner of the bar's backlight attribute (sysfs has no ACLs).
  • keys reverses that and starts tiny-dfr again.
  • devices prints what would be handed over, without root (used by the test).

etc/sudoers.d/omarchy-touchbar lets wheel run exactly the app and keys invocations without a password, the same pattern as omarchy-dns and omarchy-theme-set-browser-policy: a hotkey has no terminal to carry a password prompt. The app runs keys on every exit path, including a failed handoff.

Included

  • bin/omarchy-touchbar-now-playing: the app, one Python file. Raw DRM modesetting with a dumb buffer, cairo drawing rotated onto the portrait panel, evdev multitouch for taps. Dependencies beyond the base install: cava, python-cairo, python-gobject.
  • bin/omarchy-touchbar-handoff and etc/sudoers.d/omarchy-touchbar: the handoff described above.
  • bin/omarchy-hw-touchbar: detection by the digitizer's input device name (M1, M2 and T2 names).
  • bin/omarchy-toggle-touchbar-now-playing and bin/omarchy-install-touchbar-now-playing: the hotkey target; installs cava in a floating terminal on first use.
  • default/hypr/bindings/media.lua: Super + Ctrl + M, bound only when omarchy-hw-touchbar succeeds.
  • default/omarchy/omarchy-menu.jsonc: Trigger > Hardware > Touch Bar: Now Playing, guarded with when.
  • docs/touchbar.md and a README link.
  • tests/test-touchbar-hw.sh: detection and device discovery against fake sysfs trees for both Apple Silicon and T2 device names.

Tested

  • Daily use on a MacBook Pro 13" M2 (2022) on linux-asahi 7.1.6 and this fork at v4.0.2: handoff both ways, spectrum, album art, all three buttons, idle dimming, and clean return to tiny-dfr, including when the helper itself fails.
  • bin/omarchy commands --check passes (461 commands), tests/test-touchbar-hw.sh passes 8/8, ./test/all passes except config-test.sh and unowned-system-paths-test.sh, which need an omarchy-pkgs checkout and fail identically on an untouched quattro.
  • Not tested on a T2 Mac. The device discovery covers appletbdrm and the T2 digitizer name, and the test exercises those paths, but a T2 owner should confirm before it is claimed as supported there.

Notes for review

  • Two questions for you: whether you would rather ship this in the tree or link to it, and whether cava should be installed by an install/hardware/apple script on Touch Bar Macs instead of on first use.
  • The app also lives standalone with an install.sh at https://github.com/DataKnox/omarchy-touchbar for anyone who wants it before this lands.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Tz9ekXeW8ijPdrDtHt4Rym

DataKnox and others added 2 commits September 4, 2026 02:55
MacBook Pros with a Touch Bar run tiny-dfr on it for the F-keys, but the
bar is also a small display with a digitizer. This adds a first mini app
that draws a live audio spectrum (cava over PipeWire), the current track
with album art (from the shell's media service, so Spotify web, cliamp,
mpv and friends all work), and previous / play-pause / next buttons on it.

The app borrows the bar from tiny-dfr through a root helper,
omarchy-touchbar-handoff: "app" stops tiny-dfr and grants the user an ACL
on the bar's DRM node and digitizer (ownership for the sysfs backlight),
"keys" reverses that. A sudoers rule lets wheel run exactly those two
invocations without a password, following the DNS and theme helpers, so
the toggle can hang off a hotkey. The app runs "keys" on every exit,
including a failed handoff, so the bar is never left dark and keyless.

Also included: omarchy-hw-touchbar for detection, a Super+Ctrl+M toggle
that only binds on Touch Bar Macs, a Trigger > Hardware menu row guarded
the same way, an on-demand installer for cava, docs/touchbar.md, and a
test covering detection and the helper's device discovery against fake
sysfs trees for both the Apple Silicon and T2 device names.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tz9ekXeW8ijPdrDtHt4Rym
Numeric tests in (( )), explicit if blocks instead of && || chains and
exec-in-one-branch flow, examples only where arguments need explaining,
docs written as full lines, and the touchbar-* commands hidden from the
CLI listing: users reach the app through toggle and install, so no new
command group needs advertising.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tz9ekXeW8ijPdrDtHt4Rym
@DataKnox
DataKnox marked this pull request as ready for review September 4, 2026 03:01
@malik-na

malik-na commented Sep 9, 2026

Copy link
Copy Markdown
Member

The app handoff stops tiny-dfr before setfacl and chown, but the helper has no rollback if either step fails. Add a trap that restores any partial ACL or ownership change and restarts tiny-dfr, then cover the partial-failure paths.

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.

2 participants