Repository navigation
Keep the Bluetooth adapter pairable only while its panel is open - #14795
kwsantiago wants to merge 1 commit into
Conversation
|
87fd302 to
6a66c8e
Compare
6a66c8e to
12bccc5
Compare
12bccc5 to
9c6a901
Compare
| if pairing_token=$(omarchy-shell omarchy.bluetooth holdPairing 2>/dev/null) && | ||
| [[ $pairing_token =~ ^[0-9a-f]{32}$ ]]; then | ||
| return |
There was a problem hiding this comment.
After receiving a token, hold_pairing returns without keeping a hold outside the shell. If the shell restarts during pairing, the new BluetoothPairing starts with no tokens. With the panels closed, its gates turn pairing off even though the detached pairing command is still running. A Low Energy device can then fail to bond and be forgotten after disconnecting.
Keep command holds somewhere the replacement shell can read, or have the command renew its hold after a restart.
Knowledge Base Used: CLI command platform
|
This closes a real gap: Ready for review from my side. Related product/security discussion still open around device-initiated Just Works in #12897 — worth keeping those two stories consistent. |
|
Thanks for this. It got a first read, but not a full review yet, and nothing was run. Each item's class (bug or enhancement) needs two models to agree before the rest of the review starts. Claude Opus 5.5 read the diff against Also relevant for whoever picks this up: #12897, which is older and still open, also makes the Bluetooth panel own Next step: this goes back into the queue for a full review, with tests on a worker, once the second opinion is available. Nothing is needed from you in the meantime. |
bt-agent.serviceruns the pairing agent asNoInputNoOutput, which answers every incoming pairing request without asking. Its comment says this is safe because the adapter is only pairable while the Bluetooth panel is open and scanning. Nothing sets the adapter's Pairable property, and BlueZ brings every controller up pairable with no timeout, so that gate did not exist. What keeps unknown devices away today is that the adapter is not connectable or discoverable unless something makes it so; anything that does, such asbluetoothctl discoverable onto pair from a phone, opened a window in which a nearby device could bond with no prompt.The panel now owns the property.
PairableGate.qmlwrites Pairable on while its panel holds pairing and off otherwise: on open and close, when an adapter appears, and when BlueZ reports it changed behind the shell's back. quickshell applies the write locally at once, so the gate is event-driven with no retries; a Set that BlueZ refuses is not recovered, and the comment says so. Every controller gets a gate through anInstantiatoroverBluetooth.adapters, not only the default one the panel shows. Per-monitor instances agree through one sharedpairingHeldread over the bar's widget list, an instance being torn down drops its hold before its gate runs, and a gate replaced while its panel still holds leaves the write to its successor.omarchy-bluetooth-device pairasks the shell over IPC to hold pairing for the length of the pairing (holdPairingandreleasePairing, a counter with a 90 second safety timer), so closing the panel mid-pair cannot stop a Low Energy device from bonding, and pairs started from a terminal still bond. Without a shell to ask it sets the property itself and puts it back. The service comment now describes the real protection and its limits: the gate lives in the bar widget, so with the widget removed or the shell not running BlueZ's default stands.bluetooth-pairable-gate-test.shruns three gate instances on one fake adapter under the headless compositor and asserts exact write counts across open, close, a sibling holding, an external toggle, a late adapter, and teardown while held.bluetooth-test.shgains checks for the panel wiring and the service comment, and mocksomarchy-shellandbluetoothctlfor the hold, the no-shell fallback, an already pairable adapter, and connect.Known limitations
The shell owns the live pairable state, so a few edges fall back to BlueZ's default rather than being handled, and all of them fail safe (pairing turns off, not on). A property write BlueZ refuses is not retried. With the widget removed from the bar or the shell not running, the adapter keeps BlueZ's default. If the shell restarts during a pairing started by omarchy-bluetooth-device while every panel is closed, the fresh shell starts with no holds and its gates turn pairing off before the command finishes, so a Low Energy device can pair without bonding; connecting it again repairs it. A durable cross-restart hold would close that last window at the cost of the shell reading command state off disk, which is more machinery than a defense-in-depth gate warrants.