Skip to content
14 changes: 9 additions & 5 deletions default/systemd/user/bt-agent.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ Type=simple
# If bluetoothd is unavailable (for example in VMs or machines without a
# usable adapter), skip cleanly instead of entering a restart loop.
ExecCondition=/usr/bin/systemctl is-active --quiet bluetooth.service
# NoInputNoOutput auto-accepts pair requests. Safe because the adapter
# is only `pairable: true` when the user explicitly opens the omarchy
# bluetoothPanel and starts scanning; outside that window bluez refuses
# inbound pair attempts at a lower layer.
ExecStart=/usr/bin/bt-agent -c NoInputNoOutput
# The capability alone does NOT auto-accept. For JustWorks pairing bluez calls
# the agent's RequestAuthorization, and bt-agent answers that by prompting
# "Authorize this device pairing (yes/no)?" on stdin no matter which -c it was
# given. Under systemd stdin is /dev/null, so the prompt is never answered and
# every pairing times out. Piping `yes` is what actually makes it auto-accept.
# Safe because the adapter is only `pairable: true` when the user explicitly
# opens the omarchy bluetoothPanel and starts scanning; outside that window
# bluez refuses inbound pair attempts at a lower layer.
ExecStart=/bin/sh -c 'yes | /usr/bin/bt-agent -c NoInputNoOutput'

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.

P1 security Unrelated devices get pairing approval

yes approves requests from every device, not just the address the user selected. While omarchy-bluetooth-device enables pairing on the adapter, a nearby device can request its own JustWorks pairing and receive approval without the user choosing it. Restrict approval to the selected address rather than treating the open window as consent for every device.

How this was verified: The pair action enables adapter-wide pairability, while the separate agent receives unconditional answers with no address check.

Restart=on-failure
RestartSec=2

Expand Down