Skip to content

Enable mpris-proxy so when i take earbuds off the media pauses and vice versa (only to earbuds with this feature) - #10980

Open
othchek wants to merge 1 commit into
omacom:quattrofrom
othchek:bluetooth-mpris-proxy
Open

othchek wants to merge 1 commit into
omacom:quattrofrom
othchek:bluetooth-mpris-proxy

Conversation

@othchek

@othchek othchek commented Sep 9, 2026

Copy link
Copy Markdown

Bluetooth headsets send transport control as AVRCP passthrough — the play/pause button, and the pause that earbuds with in-ear detection emit when you take one out. bluez only routes those to a player registered on org.bluez.Media1. Omarchy registers nothing, so bluez discards them: headset buttons do nothing, and music keeps playing into an earbud that has been taken out.

mpris-proxy is that registration — it exports session MPRIS players to bluez. bluez-utils is already in omarchy-base.packages, and it ships both the binary and a mpris-proxy.service unit. The unit is just never enabled, so this costs no new dependency.

Evidence

On a JBL LIVE PRO 2 TWS, which advertises A/V Remote Control (0x110e) and A/V Remote Control Controller (0x110f).

Before — the device tree has audio endpoints and no player object, so there is nothing for bluez to route a passthrough command to:

/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX
├── sep1
└── sep2/fd0

Taking an earbud out produced no MPRIS traffic at all and nothing in the bluetoothd log.

After starting mpris-proxy, bluez accepts the player:

bluetoothd: Player registered: sender=:1.296 path=/_1_66

and removing/reinserting an earbud twice produced, on the session bus:

member=Pause   ← bud removed
member=Play    ← bud reinserted
member=Pause
member=Play

with the A2DP transport tracking it (active → idle → active). The earbuds were sending correct AVRCP the whole time; only the receiving end was missing.

Worth noting AVRCP absolute volume is handled directly by bluez/PipeWire without a registered player, so headset volume keys already worked. That makes the gap easy to miss — volume works, play/pause does not.

Why the drop-in

mpris-proxy exits 1 with Can't get on system bus when bluetoothd is unreachable:

$ DBUS_SYSTEM_BUS_ADDRESS=unix:path=/nonexistent-bus mpris-proxy
Can't get on system bus
$ echo $?
1

The unit bluez ships is Type=simple with no conditions and no Restart=, so enabling it as-is would leave a failed unit on every machine without a usable adapter. The drop-in mirrors bt-agent.service, which solves the same problem for the same reason: ConditionPathIsDirectory=/sys/class/bluetooth plus an ExecCondition on bluetooth.service let it skip cleanly, and Restart=on-failure brings it back if bluetoothd restarts underneath a running proxy. Because ExecCondition is re-evaluated on each restart, a stopped bluetooth.service ends the unit rather than looping it.

Changes

  • default/systemd/user/mpris-proxy.service.d/10-omarchy.conf — guards mirroring bt-agent.service
  • install/user/first-run/enable-user-units.sh — enable it alongside the other shipped units
  • migrations/1788959623.sh — enable it on existing installs, with the same TTY fallback used by 1786539345.sh (the bluez unit is WantedBy=default.target, not graphical-session.target)
  • test/shell.d/systemd-test.sh — cover the guards and the first-run enablement

Testing

./test/all shows the same 4 pre-existing environment-dependent failures (config, locate, snapper, unowned-system-paths) before and after this change — verified by running the full suite on a pristine quattro worktree and on this branch. No new failures.

Migration verified idempotent and clean against a temporary home:

HOME=$(mktemp -d) bash -euo pipefail migrations/1788959623.sh

Verified on hardware: with the drop-in installed and the unit enabled, exactly one mpris-proxy runs, ConditionResult=yes, the ExecCondition exits 0, and bluez registers the player. Taking an earbud out pauses playback and reinserting it resumes.

@othchek othchek changed the title Enable mpris-proxy so Bluetooth headset transport controls reach the player Enable mpris-proxy so when i take 1 earbud off the media pauses and vice versa (only to earbuds with this feature) Sep 10, 2026
@othchek othchek changed the title Enable mpris-proxy so when i take 1 earbud off the media pauses and vice versa (only to earbuds with this feature) Enable mpris-proxy so when i take earbuds off the media pauses and vice versa (only to earbuds with this feature) Sep 10, 2026
@matthewkrausse

Copy link
Copy Markdown

Another data point for this, from a different angle: multipoint auto-switching. I was trying to solve this problem and came across your PR.

Pixel Buds Pro 2, connected to both an Android phone and an Omarchy 4.0.3 laptop. Before enabling mpris-proxy, starting YouTube on the laptop never pulled the buds away from the phone. Audio went to the buds' sink, but they stayed on the phone. The same buds switch automatically to a MacBook. The multipoint firmware appears to decide based on AVRCP play status, and without a registered player, Linux never reports that it's playing.

After systemctl --user enable --now mpris-proxy.service and one reconnect, the buds switch to the laptop as soon as playback starts, matching macOS. So this PR also fixes multipoint headsets, not just transport controls.

@othchek othchek closed this Sep 16, 2026
@othchek othchek reopened this Sep 16, 2026
@othchek

othchek commented Sep 17, 2026

Copy link
Copy Markdown
Author

it's very nice to see that one change can help with two different problems thank you for your comment ❤️

@supercleanse

Copy link
Copy Markdown

Another data point, and one gap in the drop-in.

Stem gestures. AirPods Pro on a Dell XPS 14 (DA14260), Omarchy 4.0.0.alpha, bluez 5.87. Without mpris-proxy, every stem gesture (single, double, triple press) reaches the player as a plain play/pause, and Next and Previous never arrive. With it running, the session bus shows the full set:

member=Pause      ← single press while playing
member=Play       ← single press while paused
member=Next       ← double press
member=Previous   ← triple press

So this PR also fixes track skipping from AirPods, not just ear detection.

The gap. Restart=on-failure assumes mpris-proxy exits when bluetoothd goes away. It doesn't. On this machine bluetoothd aborts a few seconds after resume from suspend (five times in three days, all SIGABRT). mpris-proxy stays up through that: it logs org.bluez disappeared / org.bluez appeared and carries on, so systemd never restarts it. After one of those crashes it got stuck repeating that cycle and used 22 minutes of CPU over the next two days.

Worse, the AirPods reconnected to the restarted bluetoothd before the proxy had re-registered its players. From then on every gesture arrived as member=Play, with no Pause, Next, or Previous, until the AirPods reconnected. Restarting mpris-proxy alone didn't fix it. Restarting the proxy and then disconnecting and reconnecting the AirPods did. It's been solid since.

What I'm running locally as a workaround: a small user service that watches for org.bluez to reappear on the system bus, restarts mpris-proxy, then reconnects any connected device that offers AVRCP. I don't think that belongs in this PR, since the real bug is the bluetoothd crash, but the drop-in comment's claim that Restart=on-failure "brings it back if bluetoothd restarts underneath a running proxy" doesn't match what I saw. A user unit can't bind to the system bluetooth.service, so this may need a watcher, or at least a corrected comment.

Also, the branch now conflicts with quattro. Would be great to see it rebased, as this is a real fix for AirPods users.

@omarchybot omarchybot added the enhancement New feature or request label Oct 3, 2026
…player

Headsets send play/pause, next and previous as AVRCP passthrough, which
bluez only routes to a player registered on org.bluez.Media1. Nothing
registered one, so the commands were discarded: headset buttons and stem
gestures did nothing, and earbuds with in-ear detection could not pause
playback when one was taken out.

bluez-utils already ships mpris-proxy and its unit, disabled. Enable it,
with a drop-in mirroring bt-agent.service so it stays inert on machines
with no bluetooth instead of leaving a failed unit.
@othchek
othchek force-pushed the bluetooth-mpris-proxy branch from 2478a9c to b7a0eb4 Compare October 5, 2026 17:10
@othchek

othchek commented Oct 5, 2026

Copy link
Copy Markdown
Author

Thanks — you're right about the comment, and I've corrected it.

I checked the claim against my own journal before changing anything, and it matches what you describe. mpris-proxy logs a player event after the bus goes away, so the process is plainly still alive:

Bluetooth Adapter /org/bluez/hci0 removed
org.bluez disappeared
player org.mpris.MediaPlayer2.playerctld at :1.5 disappear   <- still running

It only stopped there because systemd stopped it at session end. So Restart= never fires for a bluetoothd restart, exactly as you found. The drop-in now says so:

Restart= covers mpris-proxy itself dying, and nothing more. It does not recover a bluetoothd restart: a running proxy survives that without exiting, logging "org.bluez disappeared" and then "org.bluez appeared", so systemd is never involved. A user unit cannot order itself against the system bluetooth.service, so recovering that case is out of reach from here.

Restart=on-failure stays, since it still covers the proxy crashing on its own, but it no longer claims more than it does. The test assertion that repeated the same wrong claim is fixed too.

I agree the watcher doesn't belong here. The re-registration race you hit — AirPods reconnecting before the proxy has re-registered, after which every gesture arrives as Play — looks like an mpris-proxy/bluez issue rather than anything this unit can reach, and the bluetoothd SIGABRT on resume is its own bug. Keeping this PR to the one change.

Good data point on the stem gestures. I'd only observed in-ear detection; that next/previous never arrive at all without the proxy makes the case broader than I'd framed it. I've folded play/pause, next and previous into the commit message and the drop-in comment so the scope is clear.

Rebased onto current quattro — the conflict was owed.service landing on the same line in enable-user-units.sh; both are enabled now. ./test/all shows the same 7 pre-existing environment-dependent failures before and after on my machine, verified against a pristine quattro worktree. No new failures.

@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Enables Bluetooth media control proxy on user systems.

The PR appears safe to merge, with a non-blocking gap in checking that the package installs the drop-in.

Findings

  1. P2 Package delivery goes unchecked ▶

Summary

Enables mpris-proxy.service so Bluetooth headset controls can reach media players.

  • Adds startup guards and restarts after proxy failures.
  • Enables the service for new and existing installs.
  • Adds source checks, but should also check that the package installs the drop-in.

othchek explicitly leaves recovery after a Bluetooth daemon restart outside this drop-in’s scope because the proxy stays running.

Reviews (1) · Last reviewed commit: "Enable mpris-proxy so Bluetooth headset ..."

Comment on lines +108 to +115
mpris_dropin="$ROOT/default/systemd/user/mpris-proxy.service.d/10-omarchy.conf"
grep -Fx 'ConditionPathIsDirectory=/sys/class/bluetooth' "$mpris_dropin" >/dev/null ||
fail "the AVRCP bridge is pulled in on machines with no bluetooth subsystem"
grep -Fx 'ExecCondition=/usr/bin/systemctl is-active --quiet bluetooth.service' "$mpris_dropin" >/dev/null ||
fail "mpris-proxy exits 1 when bluetoothd is unreachable, so without this it leaves a failed unit instead of skipping"
grep -Fx 'Restart=on-failure' "$mpris_dropin" >/dev/null ||
fail "a crashed proxy stays dead and headset transport controls silently stop working"
pass "the AVRCP bridge stays inert without bluetooth and recovers from its own crash"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Package delivery goes unchecked

These tests check the repository copy of the drop-in, but not whether the package installs it where systemd reads it. If the package omits it, the tests still pass while users receive none of these guards. Add the drop-in and its destination to package_defaults in config-test.sh, which already checks package delivery for other service defaults.

@omarchybot omarchybot removed the enhancement New feature or request label Oct 13, 2026
@jandrusk

Copy link
Copy Markdown

Nice drop-in — the bluetooth ConditionPathIsDirectory / ExecCondition pairing matches how we keep bt-agent inert, and the field reports on stem gestures / multipoint are convincing.

One blocker before merge: migrations/1788959623.sh collides with open #11064 (pre-T2 Cirrus speakers), which already owns that timestamp. Please regenerate a unique migration filename and push again; the rest looks good.

@omarchybot

Copy link
Copy Markdown
Collaborator

Classified, not yet verified. Two models read this pull request separately and did not agree on what it is: Claude Opus 5.5 read it as an enhancement, since it turns on a service Omarchy has never enabled and adds a drop-in and a migration for it. Codex Medium read it as a bug fix, since headset play/pause, next/previous and in-ear pause do nothing on a stock install today. Both readings hold up, so it carries no class label for now, and it is not run on a worker until the class is settled, because that decides whether it is verified as a bug fix or waits to be asked for as a feature.

One thing checked meanwhile: migrations/1788959623.sh is also added by #11064, which is still open, so whichever lands second needs a new timestamp. No other open pull request enables mpris-proxy. #15097, which restarts bt-agent when org.bluez loses its owner, is the closest neighbour to the bluetoothd-restart gap the drop-in comment now describes, but it does not touch this unit.

Waiting on the maintainer to settle the classification.

@AshutoshGotpagar

Copy link
Copy Markdown

Another data point, plus one gap I hit after enabling mpris-proxy.

CMF Buds Pro 2 on an M1 Pro MacBook Pro (Omarchy 4.5.0-3, bluez 5.87). Before mpris-proxy, in-ear detection arrived as XF86AudioPause/XF86AudioPlay keys, which Omarchy binds to the media.playPause toggle, so resume was unreliable (filed as #19174). With mpris-proxy enabled, removing a bud pauses and reinserting it resumes, reliably and much faster.

Gap: the media OSD no longer appears. mpris-proxy calls Play/Pause on the MPRIS player directly, which bypasses the media key binds and therefore the OSD that media.playPause shows. Headset play/pause and in-ear detection now change playback with no on-screen feedback. Keyboard media keys still show it.

My local workaround is a user service that watches the session bus for org.mpris.MediaPlayer2.Player.{Play,Pause,PlayPause} calls. It filters to callers whose process is mpris-proxy, then runs omarchy-shell shell summon omarchy.osd with the resulting state and track. A cleaner fix might be for the media service itself to show the OSD on a PlaybackStatus change it didn't initiate, or at least on ones that come from mpris-proxy.

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.

6 participants