Skip to content

Keep the Bluetooth pairing agent from skipping late USB adapters - #8572

Closed
MrBazzieB wants to merge 1 commit into
omacom:quattrofrom
MrBazzieB:fix/bt-agent-late-adapter
Closed

MrBazzieB wants to merge 1 commit into
omacom:quattrofrom
MrBazzieB:fix/bt-agent-late-adapter

Conversation

@MrBazzieB

Copy link
Copy Markdown
Contributor

What

The session bt-agent no longer skips forever when /sys/class/bluetooth is missing at login. It waits for bluetoothd and the adapter sysfs node, then registers as the default pairing agent. If nothing appears, it exits 0 so machines without Bluetooth do not restart-loop.

Why

Omarchy's Bluetooth panel pairs with bluetoothctl pair. That needs a registered BlueZ agent. The user unit used ConditionPathIsDirectory=/sys/class/bluetooth plus ExecCondition= on bluetooth.service. A failed Condition/ExecCondition skips the unit; Restart= does not apply.

On a MacBookPro12,1 (Broadcom USB adapter) that looks like:

bt-agent.service: skipped, unmet condition check ConditionPathIsDirectory=/sys/class/bluetooth

Then pairing from Super+Ctrl+B logs:

src/device.c:new_auth() No agent available for request type 2
device_confirm_passkey: Operation not permitted

Reproduced pairing Logitech MX Anywhere 3S and Pebble Keys 2 K380s. They advertised fine; the GUI could not confirm the passkey because no agent was running. bluetoothctl --agent NoInputNoOutput pair … succeeded immediately.

Related

This is separate from the trusted-but-unpaired state machine (#7879 / #7880) and from showing keyboard passkeys (#8485 / #6877). Those still matter. Even with them, this skip leaves the panel with no agent on late USB adapters.

#6877 keeps ConditionPathIsDirectory=/sys/class/bluetooth, so it would still skip on this hardware.

Test

  • bash test/shell.d/bluetooth-test.sh
  • bash test/shell.d/systemd-test.sh
  • ./test/cli

./test/all: bluetooth/systemd tests pass. Remaining failures (config, launch-about, snapper, unowned-system-paths, plus flaky theme-install-guards / runtime-smoke) also fail on quattro here without this change (missing omarchy-pkgs checkout / compositor).

ConditionPathIsDirectory=/sys/class/bluetooth skips bt-agent forever when
the adapter sysfs node is missing at graphical-session start. USB adapters
(Broadcom on Intel MacBooks, dongles) often appear a few seconds later, so
the Omarchy Bluetooth panel's bluetoothctl pair fails with "No agent
available". Wait for bluetoothd and sysfs, then exec bt-agent. Exit 0 if
nothing shows up so machines without Bluetooth do not restart-loop.
Copilot AI balanced review requested due to automatic review settings August 27, 2026 11:21

Copilot AI left a comment

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.

Pull request overview

Adds a bounded startup wrapper so the BlueZ pairing agent can handle adapters appearing after login.

Changes:

  • Waits up to 60 seconds for Bluetooth readiness.
  • Reloads and restarts existing user services.
  • Adds service configuration and shell tests.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
bin/omarchy-bluetooth-agent-start Adds bounded readiness polling before launching the agent.
default/systemd/user/bt-agent.service Replaces permanently skipping conditions with the wrapper.
migrations/1787815267.sh Reloads and restarts the updated user service.
test/shell.d/bluetooth-test.sh Tests wrapper startup outcomes.
test/shell.d/systemd-test.sh Verifies the updated unit configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread migrations/1787815267.sh
# at graphical-session start (Broadcom on Intel MacBooks, USB dongles). Reload
# so the user manager picks up the wait-then-exec wrapper, then bounce a live
# or skipped agent. Login starts it for everyone else.
systemctl --user daemon-reload
[[ ! -s $device_tmp/agent-ran ]] || fail "pairing agent is not started without an adapter"
pass "pairing agent start exits 0 when no adapter appears"

# Adapter already present: exec bt-agent immediately.
@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #9131, which covers the same Bluetooth agent wait. I keep that one open and close this one to consolidate review.

If you feel this is the wrong decision, please open the PR again with a note on the difference.

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.

3 participants