Skip to content

Show Bluetooth pairing passkeys so keyboards can bond - #6877

Closed
gabriel-laet wants to merge 6 commits into
omacom:quattrofrom
gabriel-laet:bluetooth-keyboard-passkey-pairing
Closed

gabriel-laet wants to merge 6 commits into
omacom:quattrofrom
gabriel-laet:bluetooth-keyboard-passkey-pairing

Conversation

@gabriel-laet

@gabriel-laet gabriel-laet commented Aug 14, 2026 •

Copy link
Copy Markdown

What

BLE HID keyboards that require a passkey (HHKB Studio and similar) cannot finish pairing from the Omarchy Bluetooth panel.

Why

Three things stacked:

  1. bt-agent ran as NoInputNoOutput, which auto-accepts Just Works but cannot display a PIN.
  2. omarchy-bluetooth-device pair trusted the device even when bluetoothctl pair failed, then tried to connect.
  3. The panel treated trusted as already paired, so the next click only connected. The keyboard was left trusted, unpaired, and stuck.

Reproduced on Omarchy 4.0 with an HHKB Studio: the agent looped Authorize this device pairing (yes/no)?, pairing timed out, the device stayed Trusted: yes / Paired: no, and HOG connect failed.

Change

  • New omarchy-bluetooth-agent (KeyboardDisplay) shows the six-digit passkey via omarchy-notification-send. Just Works still auto-accepts.
  • Pair only trusts and connects after a successful bond (60s timeout).
  • Panel connects only when paired || bonded. Trusted-without-a-bond pairs again.
  • Migration restarts the user bt-agent.service so existing sessions pick up the new agent.

Test

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

Mice/headphones that already used Just Works are unchanged. Keyboards now get a notification with the code to type on the device.

Fixes #8485, #7879, #9676, #6992

NoInputNoOutput cannot display a PIN, and a failed pair still trusted
the device so the panel connected instead of pairing again. BLE HID
keyboards such as the HHKB never finished bonding from the panel.
Copilot AI balanced review requested due to automatic review settings August 14, 2026 17:37

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 Bluetooth passkey display support for BLE keyboards and prevents failed pairings from leaving devices trusted but unbonded.

Changes:

  • Adds a notification-based BlueZ pairing agent.
  • Gates trust/connect operations on successful pairing.
  • Updates panel bond detection, migration, and 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 6 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
bin/omarchy-bluetooth-agent Implements the BlueZ passkey agent.
bin/omarchy-bluetooth-device Trusts and connects only after successful pairing.
default/systemd/user/bt-agent.service Launches the new agent.
migrations/1786728635.sh Reloads and restarts the user service.
shell/plugins/panels/bluetooth/Model.js Adds bond-state projection and detection.
shell/plugins/panels/bluetooth/Panel.qml Re-pairs trusted but unbonded devices.
test/shell.d/bluetooth-test.sh Tests bond handling and pairing sequencing.
test/shell.d/systemd-test.sh Tests agent service configuration.

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

dhh and others added 3 commits August 15, 2026 03:17
Migrations run under bash -euo pipefail, so an unguarded systemctl --user
call aborts the whole run for anyone without a live user manager.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Critical toasts never expire in the Omarchy shell and survive restarts, so
a passkey nobody typed stayed on screen for good.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
It only arrives transitively through uwsm today.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 15, 2026 10:17

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

Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (1)

default/systemd/user/bt-agent.service:17

  • The service now runs Omarchy’s custom Agent1 implementation, but its unit metadata still describes the old auto-accept agent and points operators to bt-agent(1). Update the description and documentation target so systemctl status links to the API this process actually implements.
ExecStart=/usr/bin/omarchy-bluetooth-agent

The unit now runs omarchy-bluetooth-agent, not bt-agent, so drop the
stale man:bt-agent(1) reference and describe the passkey behavior.
Copilot AI review requested due to automatic review settings August 20, 2026 00:56

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

Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (1)

migrations/1786728635.sh:11

  • Both required migration actions suppress failure, so a transient daemon-reload or restart error still marks the migration complete and leaves the existing session running the old agent indefinitely. Let these commands fail so the migration runner can retry; only reset-failed is safe to keep best-effort.
systemctl --user daemon-reload >/dev/null 2>&1 || true

if systemctl --user is-enabled --quiet bt-agent.service 2>/dev/null; then
  systemctl --user reset-failed bt-agent.service 2>/dev/null || true
  systemctl --user restart bt-agent.service || true

omarchy-base.packages only feeds the ISO pacstrap and the quattro upgrade,
so an existing install never received python-dbus from the base list
alone. The migration restarted bt-agent.service into a unit whose new
ExecStart fails on `import dbus`, and Restart=on-failure then looped it
every two seconds.

Install the package first, and let a failed install stop the migration so
it stays pending instead of bouncing the agent without its dependency.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KKMv5b5JWcHxoX4QC79BPJ
@gabriel-laet

Copy link
Copy Markdown
Author

Pushed 58106d4: the migration now runs omarchy-pkg-add python-dbus before restarting bt-agent.service. omarchy-base.packages only feeds the ISO pacstrap and the quattro upgrade, so an existing install never received the new dependency and the restarted unit would have looped on import dbus every two seconds. A failed install now stops the migration so it stays pending. Covered by test/shell.d/bluetooth-agent-migration-test.sh.

The branch still merges cleanly onto current quattro (271 commits later) and the Bluetooth, systemd and migration tests pass on the merged tree.

Related reports this also resolves: #8485 (MX Mechanical Mini passkey), #7879 / #7880 (trusted-but-unbonded devices never re-pair), #9676 (bt-agent prompts without a terminal) and #6992 (missing /usr/bin/bt-agent restart loop), since the unit no longer depends on bluez-tools' agent. #8572 (late USB adapters) is complementary and does not conflict.

@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #9965, which covers the same Bluetooth pairing agent. 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.

Quickshell Bluetooth panel cannot pair devices that require a displayed passkey

5 participants