Skip to content

Scope bluetooth rfkill block to HCI adapters, sparing platform switches - #12753

Open
anandude wants to merge 6 commits into
omacom:quattrofrom
anandude:fix-bluetooth-rfkill-scope
Open

anandude wants to merge 6 commits into
omacom:quattrofrom
anandude:fix-bluetooth-rfkill-scope

Conversation

@anandude

@anandude anandude commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #7936.

Problem

omarchy-bluetooth-power off runs rfkill block bluetooth, a type-wide block (RFKILL_OP_CHANGE_ALL). On laptops that expose a platform Bluetooth rfkill switch next to the adapter's own hci0 switch (ThinkPads via thinkpad_acpi, Dells via dell-laptop, Ideapads, ...), that also blocks the platform switch — and the embedded controller answers by cutting USB power to the Bluetooth module. hci0 disappears from the kernel entirely instead of going Powered: no, so the panel loses its way back on. This is the root cause behind the "widget disappears" report in #6956 on this class of hardware, where the panel-side fixes (#7048, #7065) are insufficient on their own.

Change

  • bin/omarchy-bluetooth-power: new block_adapters() blocks only the hci* rfkill indexes (rfkill -n -o ID,DEVICE list bluetooth + awk), used by both off and the power-off half of toggle. The per-adapter soft block still drops the adapter to Powered: no, and systemd-rfkill persists it under the adapter's own ID, so off survives a reboot the same way. With no HCI switch in sight (no radio, or an already-removed one) it falls back to the type-wide block, preserving the old behavior there. on stays rfkill unblock bluetooth since unblocking the platform switch is harmless.
  • test/shell.d/bluetooth-test.sh: the mock rfkill now answers list from MOCK_RFKILL_LIST (empty by default, so all legacy assertions keep exercising the fallback unchanged), plus 5 new tests: blocks only the HCI index, skips the type-wide block when adapters exist, never touches the platform switch, scoped toggle-off, and type-wide fallback without adapters.

Verification

  • bash test/shell.d/bluetooth-test.sh: all pass, including the 5 new ones
  • bash test/shell.d/bin-style-test.sh: pass
  • ./test/cli: 112 ok, 0 failures
  • ./test/shell: only the 5 pre-existing environment failures (missing omarchy-pkgs checkout, omasnap, Qt portal) — confirmed identical on the clean tree
  • Read-only check on real hardware (Ideapad platform switch + hci0): the ID extraction yields just the hci0 index

Note

Known limitation from the issue discussion: if the adapter is re-enumerated (e.g. suspend/resume), the new rfkill inherits the global type state, which a per-index block never sets — so a resumed adapter could come back unblocked. A udev rule re-applying the saved state would cover that; kept out of this PR to stay atomic. Happy to follow up if you want it here.

Fixes #12599

Fixes #15112

Fixes #16501

@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

One error-reporting regression found at 8af094e3.

Verified: With synthetic rfkill/bluetoothctl backends, off and powered toggle select the HCI indexes instead of the accompanying platform switch, including multiple adapters. The no-HCI case retains the previous type-wide fallback.

Preserve failures from per-adapter blocks

In block_adapters(), each rfkill block "$id" result is discarded. Once an ID was listed, the final if skips its body and returns success.

Synthetic failure through the real helper:

                         Base        PR
rfkill block exits         1          1
Bluetooth state        unchanged  unchanged
helper off exits           1          0

A concrete applicable condition is readable /dev/rfkill without write permission: listing can succeed while blocking fails. This permission condition was modeled, not tested against a real radio.

Impact: CLI callers receive success even though Bluetooth was not turned off. The backend error still reaches stderr; this does not introduce a new panel error-display problem.

Suggested change: Attempt all selected adapters, aggregate their block failures, and return nonzero if any block fails. Preserve the fallback command's status as well.


Review information

Test scope: Pinned source review and isolated synthetic-backend checks. No physical radio, firmware, UI, reboot or suspend/resume validation; the full upstream suite was not run.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium initial inspection and synthesis, independent Opus 5.5 High and GPT 6 Sol Xhigh technical reviews, and verification of the reported claim against source and retained targeted evidence.

@anandude

Copy link
Copy Markdown
Contributor Author

Fixed in 9767161 — block_adapters attempts every listed adapter, returns nonzero if any block fails, and keeps the fallback command's own status. Added a failing-block case to the bluetooth test using your readable-without-write example. Whole bluetooth file green.

@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up at 97671612 to the earlier review and the author's reply. The per-adapter block failure finding is resolved. No new issue was found in this commit.

Verified: block_adapters() now attempts every listed HCI adapter, returns nonzero if any block fails, and returns the type-wide fallback's own status when no adapter is listed. Results through the real helper with synthetic rfkill/bluetoothctl backends:

Helper exit status                          base   8af094e3   97671612
off, listing allowed, blocking denied         1        0          1
powered toggle, same condition                1        0          1
off, two adapters, first ID fails             0        0          1   (both IDs attempted)
off, no HCI adapter, fallback exits 3         3        3          3

(Base exits 0 in the two-adapter row because it issues one type-wide block, which the synthetic model lets succeed.)

The util-linux source matches the modeled condition: rfkill opens /dev/rfkill read-only to list and read-write to block, and exits nonzero when that open fails. The new test case fails with the 8af094e3 helper and passes at 97671612. HCI-only selection still holds, with the platform switch never blocked, including with two adapters. The no-adapter fallback is unchanged.

Author's "whole bluetooth file green": the shell section of test/shell.d/bluetooth-test.sh passes in full. Its Node section (panel files, unchanged by this PR) was not run.

Optional test improvement: the new case uses one adapter and fails every block. Three altered helpers still pass it: one that stops at the first failure, one that escalates a failure to rfkill block bluetooth (which would trip the platform switch), and one whose fallback returns 0. A two-adapter listing where only one ID fails, asserting both IDs are attempted and no rfkill block bluetooth is issued, would catch the first two. A platform-only listing with a failing block would catch the third.


Review information

Test scope: Pinned source review of 97671612 and the relevant util-linux and systemd source, plus isolated checks with synthetic rfkill/bluetoothctl backends (the shell section of the bluetooth test and a base/8af094e3/97671612 status matrix). No physical radio, real /dev/rfkill permissions, firmware, UI, reboot or suspend/resume validation.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh (source review and isolated synthetic runs) and GPT 6 Sol Xhigh (source-only) technical assessments of this follow-up, and an Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@anandude

Copy link
Copy Markdown
Contributor Author

Done in d03abf5 — added the two-adapter partial failure case (fail ID 1 of hci0+hci1, asserting both IDs are attempted, nonzero exit, and no type-wide block) plus a failing-fallback case. I checked all three broken variants you named against it: early return fails on "attempts every adapter", type-wide escalation fails on "does not escalate", forced success fails on the exit assertions.

@llstrk

llstrk commented Sep 24, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up at d03abf55 to the previous review and the author's reply. The optional test improvement is resolved. No new issue was found in this commit.

Verified: d03abf55 changes only test/shell.d/bluetooth-test.sh. bin/omarchy-bluetooth-power is byte-identical to 97671612, so the earlier resolution of the per-adapter block failure finding still holds.

Verified: the two added cases (two adapters with only ID 1 failing; platform-only listing with a failing fallback) catch each altered helper described in the previous review. Altered helpers were written from those descriptions and run with the test file's synthetic rfkill/bluetoothctl backends:

Altered helper                                   97671612 test   d03abf55 test fails at
stops at the first failed block                  passes          "attempts every adapter despite a failure"
escalates to rfkill block bluetooth, exits 1     passes          "does not escalate a partial failure ..."
escalates, returns the type-wide block's status  passes          "reports a partially failed adapter block"
fallback returns 0                               passes          "reports a failed fallback block"
unchanged PR helper                              passes          passes

The author's account holds, with one detail: an escalating helper that returns the type-wide block's success is caught by the exit check just before the escalation check. Every variant still fails the updated test. The earlier checks in the file produce identical results under both test versions.


Review information

Test scope: Pinned source review of d03abf55 and its diff from 97671612, plus isolated runs of the shell section of test/shell.d/bluetooth-test.sh against the pinned helper and altered helpers, with synthetic backends. The file's Node section was not run. No physical radio, real /dev/rfkill permissions, firmware, UI, reboot or suspend/resume validation.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh (source review and isolated synthetic runs) and GPT 6 Sol Xhigh (source-only) technical assessments of this follow-up, and an Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot omarchybot added bug Something isn't working compatibility Make Omarchy work better on everything! labels Sep 27, 2026
@symonbaikov

Copy link
Copy Markdown

Tested on real hardware at d03abf55: ThinkPad P15v Gen 3 (21D8), Intel BT 8087:0033, omarchy 4.0.4, kernel 7.2.5.

Before (4.0.4): omarchy-bluetooth-power off → usb 3-10: USB disconnect, hci0 gone, panel shows "No adapter" with no toggle; only rfkill unblock bluetooth recovers it.

With this PR: off → tpacpi_bluetooth_sw stays unblocked, only hci0 is blocked, adapter stays on the bus at Powered: no; systemd-rfkill saves 1 for the hci0 USB path and 0 for the platform switch. on → Powered: yes. No USB disconnect in the kernel log.

Side note (not caused by this PR): blocking hci0 while the Intel firmware is still loading left bluetoothd failing Failed to add device … (0x03) for bonded LE HID devices until a bluetoothd restart. Looks related to #8022.

@gregstephensjr

Copy link
Copy Markdown

Tested on real hardware at d03abf55: ThinkPad T420, Broadcom BCM2045B (0a5c:217f) on USB 2 (ehci-pci), omarchy 4.0.4, kernel 7.2.5. This is an older generation and a different radio vendor from the P15v report above.

This run goes through the bar widget, not only the helper. I cloned omarchy.bluetooth, pointed toggleBluetooth() at this PR's helper, restarted the shell, and fired the toggle with qs ipc call omarchy.bluetooth toggleBluetooth. That call runs the same function as a click.

Before, with the 4.0.4 helper:

on->off  rfkill: block set for type bluetooth   tpacpi_bluetooth_sw=blocked, no adapter
         kernel: usb 1-1.4: USB disconnect
off->on  rfkill: (nothing)                       adapter is null, toggle returns early, widget hidden

With this PR, two full cycles, identical both times:

on->off  rfkill: block set for id 9              tpacpi_bluetooth_sw=unblocked hci0=blocked Powered=no
off->on  rfkill: unblock set for type bluetooth  tpacpi_bluetooth_sw=unblocked hci0=unblocked Powered=yes

The kernel logged no USB disconnect. While off, systemd-rfkill stored 1 in pci-0000:00:1a.0-usb-0:1.4:1.0:bluetooth and 0 in platform-thinkpad_acpi:bluetooth, so the off state persists on the adapter's own switch.

The adapter never leaves D-Bus, so the stock Panel.qml works unchanged on this machine. On this class of hardware this PR also resolves #12599 and #13523, which both come from the adapter dropping off the bus.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at d03abf559bcedf1872bfc52086c11fda6e8d85f4 against quattro. Nothing wrong found in the change. It is waiting on a hardware confirmation from the reporter of #7936.

What ran, on a disposable Omarchy VM (kernel 7.2.5, util-linux 2.42.3):

  • ./test/cli: 112 ok, 0 failures. test/shell.d/bluetooth-test.sh: 56 passed. test/shell.d/bin-style-test.sh: 2 passed.
  • With the quattro helper put back under this branch's tests, bluetooth-test.sh fails at "bluetooth blocks only the HCI adapter". The new tests check the scoping and pass only with the fix.
  • I also ran the real rfkill against a virtual HCI controller (hci_vhci). quattro's off logs block set for type bluetooth, which is the type-wide operation that also blocks a platform switch. This branch's off logs block set for id 2, which is only the adapter. The rfkill -n -o ID,DEVICE parsing picks out the right index from real output. Both versions drop the adapter to blocked.

What a VM cannot show: a VM has no platform switch, so it cannot reproduce the USB disconnect itself. Two people have tested this head on ThinkPads in the comments above: @symonbaikov on a P15v Gen 3 and @gregstephensjr on a T420. Both saw no USB disconnect, and the platform switch stayed unblocked. Because this fix depends on hardware, the confirmation that settles it has to come from the account that reported the bug.

@DrakeMorrison, could you try this exact commit on the E16 Gen 1? The helper is self-contained, so you can run it without installing anything:

curl -fsSLo /tmp/omarchy-bluetooth-power https://raw.githubusercontent.com/anandude/omarchy/d03abf559bcedf1872bfc52086c11fda6e8d85f4/bin/omarchy-bluetooth-power
bash /tmp/omarchy-bluetooth-power off
rfkill list bluetooth; bluetoothctl show | grep Powered; journalctl -k --since "-1min" | grep -i "usb disconnect"
bash /tmp/omarchy-bluetooth-power on

It works if tpacpi_bluetooth_sw stays unblocked, hci0 is blocked but still listed, the adapter shows Powered: no, and there is no USB disconnect. After on it should be back to Powered: yes.

Related: 12585, 13655, 13204, 10749, 7065, 13806, 12241, 10003 and 11252 all change the panel so it copes with an adapter that has disappeared. This PR stops the adapter from disappearing on this class of hardware, so the two work at different layers and don't compete. Which of the panel PRs to take is a separate decision for the maintainer.

Who checked it: reviewed by Claude Opus 5.5. The configured second opinion (Codex Medium) did not run because the daily review allowance was used up, so this review has not been checked by a second model.

@echennells

Copy link
Copy Markdown

Tested d03abf55 on a ThinkPad T14 Gen 2a (20XLS0A300). Bluetooth is a Realtek RTL8852AU (USB 0bda:4852) behind tpacpi_bluetooth_sw. That's a third radio vendor after the Intel (P15v) and Broadcom (T420) reports above. Setup: Omarchy 4.0.4-1, kernel 7.2.5-3-omarchy, bluez 5.87.

Method: this PR's omarchy-bluetooth-power on 4.0.4, with the stock 4.0.4 panel (a copy that only adds logging of visible/adapter with ms timestamps). I drove it through toggleBluetooth over IPC and the CLI, with rfkill event and the kernel log running.

  • 5 panel off/on and 3 CLI off/on: only hci0 was blocked and unblocked, and tpacpi_bluetooth_sw never changed. There was no USB disconnect, the adapter never left D-Bus, and the widget never hid (0/16), showing "Turned Off" with the switch.
  • Turning on takes ~0.24 s end to end (omarchy-bluetooth-power on returns in 233 ms and is powered 8 ms later). The type-wide block took 1.1–1.5 s on this machine, because it was a cold start: USB re-enumeration plus firmware load.
  • 6 reboots with this helper: no radio cut at boot, against a USB disconnect 0.05–0.21 s after the restore before. bt-agent started 6/6, where it was skipped on 2 of 3 earlier off-boots. The widget was on the bar from shell start.

What this PR can't fix on ThinkPads: "off" still doesn't survive a reboot (5/5). The saved hci0 block is restored, then thinkpad_acpi has a stale SW_RFKILL_ALL event queued. At the first login it reaches the kernel's rfkill input handler, which unblocks every radio. That's a kernel bug; details and traces are in #13342 (#13342 (comment)). It's independent of this change, which I'd still merge.

Note for anyone testing reboots: systemd-rfkill saves the state only after ~5 s idle, so wait that long after turning Bluetooth off.

Tested with help from Claude Code; every run was on my machine.

@omarchybot

Copy link
Copy Markdown
Collaborator

Follow-up at the same head, d03abf559bcedf1872bfc52086c11fda6e8d85f4, now checked against current quattro (d9b970dd). Still nothing wrong found, and still waiting on @DrakeMorrison's confirmation on the E16 Gen 1, as asked above.

What's new since my last comment:

  • The second opinion ran this time. Codex Medium reviewed the diff and found no defect. It checked the rfkill -n -o ID,DEVICE parsing against util-linux, that hciN is the rfkill name for every HCI adapter including btusb ones, that no other caller in bin/, shell/, install/, migrations/ or default/ blocks bluetooth type-wide, and that the new tests fail without the fix. One small point: systemd-rfkill keys its saved state by the device path, not the rfkill ID, so "under the adapter's own ID" in the comment at bin/omarchy-bluetooth-power:71 is loosely worded. Behaviour is unaffected, and @gregstephensjr's saved-state paths above show the same thing. It had read my earlier comment, so its agreement isn't fully independent.
  • Rerun on a disposable Omarchy VM, with this branch merged into current quattro: ./test/cli 117 ok, 0 failures. bluetooth-test.sh 56 passed. With the quattro helper put back, it fails at "bluetooth blocks only the HCI adapter". On a virtual HCI controller, quattro's off logs block set for type bluetooth and this branch's logs block set for id 1.
  • @echennells tested on a third radio vendor (Realtek, T14 Gen 2a). Their finding that "off" still doesn't survive a ThinkPad reboot is a separate kernel issue, tracked in Bluetooth does not retain OFF setting between reboots #13342, and not something this PR causes.

Overlap for the maintainer: #13667 and #13867 both edit the same off lines in bin/omarchy-bluetooth-power. #13667 keeps the type-wide rfkill block bluetooth, and its new login restore path uses it too. On this hardware, that would trip the platform switch again at every login where Bluetooth was left off. #13867 drops the rfkill block from off in favour of Powered=false, which is a different design. Whichever lands second will need reconciling.

@vstoyanov

Copy link
Copy Markdown

block_adapters() still enters the invalid state.

When rfkill -n -o ID,DEVICE list bluetooth shows no hci* device, lines 85–87 run rfkill block bluetooth. That is the type-wide block this PR exists to remove. The platform switch is type bluetooth, so this branch blocks tpacpi_bluetooth_sw / dell-bluetooth and the embedded controller cuts USB power to the radio. The adapter leaves the bus, which is the #7936 failure.

The new test locks that in. platform_only_rfkill_list is only tpacpi_bluetooth_sw, and lines 304–307 require the command to log rfkill block bluetooth.

This runs whenever no hci* index exists yet: the controller is still probing, enumeration has failed and the platform switch is the only Bluetooth rfkill, and migration 1786380259 calls off because is-on is false while no controller is registered. The "already removed, so harmless" reading misses those windows.

The guard is to block hci* indexes and issue no type-wide block. With no hci* device, off should return without blocking. Please drop the fallback and the test that requires it.

@anandude

Copy link
Copy Markdown
Contributor Author

Good catch, and thank you for the trace — the mechanism is exactly as you describe, and that fallback was the one path left where the platform switch could still be tripped.

I've kept the fallback, but only for a case with no platform switch in it. Behaviour at cc5d9ba:

Listing (rfkill -n -o ID,DEVICE list bluetooth) Block issued
Any hci* switch those indexes only (unchanged)
Only non-HCI switches (platform switch present) none — off returns without touching the radio
Succeeded, named nothing at all rfkill block bluetooth
Failed none

So the type-wide block now fires only when the read succeeded and showed no switch whatsoever. That is the one case where there is no platform switch to trip, and issuing no block there would leave off not holding: an adapter that registers afterwards comes up unblocked and bluetoothd powers it on. Your case — a platform switch listed with no hci* — now issues no block at all, and a failed listing is no longer counted as an empty one for the same reason you gave: the failed read may have missed a switch it never showed.

The tests assert each end. platform_only_rfkill_list now expects no block at all, so the old assertion requiring rfkill block bluetooth is gone; the empty listing still expects the type-wide block; and a new MOCK_RFKILL_LIST_FAIL case pins that a failed listing issues no block and exits cleanly.

Verified at cc5d9ba: bluetooth-test.sh 58/58, bin-style-test.sh and ./test/cli green.

I also picked up the wording note from the earlier review: the header comment no longer claims systemd-rfkill keys its saved state by rfkill ID — it uses the device path.

If you'd rather the type-wide block go entirely, empty listing included, say so and I'll drop it — that is the only place it is left.

@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

Changes omarchy-bluetooth-power to block individual hci* switches without blocking platform switches.

  • Bluetooth turns off adapters without tripping platform switches.

Reviews (3) · Last reviewed commit: "Merge quattro into fix-bluetooth-rfkill-..." · Reviewed by Greptile

A failed `rfkill list` (no /dev/rfkill, or one that cannot be opened) left block_adapters() returning 0 with rfkill's error discarded, so `off` reported success while the radio stayed on; quattro exits 1 with the error there. Keep blocking nothing on a failed listing, but return its status and let the error through, as a refused block already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed cc5d9bad from @anandude and pushed one small fix on top, so the head is now 048d6fa686d3e356e9a23d05820b001541846d7f. This waits on a hardware confirmation from the reporters.

The new commit holds. A platform switch listed with no hci* switch now gets no block, which closes the path @vstoyanov found. The type-wide block is kept only when the listing succeeds and is empty, where there is no platform switch to trip. The tests pin each case.

What I fixed: when rfkill list itself failed (for example, /dev/rfkill could not be opened), off blocked nothing, threw away rfkill's error, and exited 0 with the radio still on. quattro exits 1 with rfkill: cannot open /dev/rfkill in the same situation, and 9767161 already made a refused block fail the command for the same reason. In 048d6fa, a failed listing still blocks nothing, but off now returns rfkill's status and lets its error through (bin/omarchy-bluetooth-power:87). The failed-listing test now requires the failure. It is a 9-line change across the helper and its test.

What ran, on a disposable Omarchy VM (util-linux 2.42.4), with the branch merged into current quattro (0c93f614):

  • ./test/cli: 125 ok, 0 failures. test/shell.d/bluetooth-test.sh: 58 passed. test/shell.d/bin-style-test.sh: 2 passed.
  • The quattro helper fails these tests at "bluetooth blocks only the HCI adapter". The d03abf55 helper fails at "bluetooth issues no block when only a platform switch is listed". The cc5d9bad helper fails at "bluetooth reports a failed listing".
  • I also ran the real rfkill:
    • With hci0 present on a virtual controller, off changes only that index (kernel event op 2, not the type-wide op 3).
    • With nothing listed, off issues the type-wide block, and an hci0 registered afterwards comes up blocked.
    • With /dev/rfkill moved away, off now prints the error and exits 1.

What a VM cannot show: a VM has no platform switch, so it cannot reproduce the USB disconnect itself. The ThinkPad reports above were all at d03abf55. The platform-switch path has changed since then, and a fix that depends on hardware needs confirmation on the current head from the people who reported the bug. @DrakeMorrison (#7936) and @alhasapi (#12599), could you try this exact commit? The helper is self-contained, so nothing needs installing:

curl -fsSLo /tmp/omarchy-bluetooth-power https://raw.githubusercontent.com/anandude/omarchy/048d6fa686d3e356e9a23d05820b001541846d7f/bin/omarchy-bluetooth-power
bash /tmp/omarchy-bluetooth-power off; echo "exit $?"
rfkill list bluetooth; bluetoothctl show | grep Powered; journalctl -k --since "-1min" | grep -i "usb disconnect"
bash /tmp/omarchy-bluetooth-power on

It works if off exits 0 and the platform switch (tpacpi_bluetooth_sw, dell-bluetooth or ideapad_bluetooth) stays unblocked. hci0 should be blocked but still listed, the adapter should show Powered: no, and there should be no USB disconnect. After on, it should show Powered: yes again.

Who checked it: reviewed by Claude Opus 5.5, with Codex Medium as the second opinion over two rounds. On cc5d9bad, it agreed that the failed-listing exit was a defect and proposed the same contained fix. I had put that question to it, so its agreement is not independent. It found nothing else: the empty-listing check is correct for rfkill -n -o ID,DEVICE output, the negative test assertions are not vacuous, and the change is proportionate. On 048d6fa, it found no defects. Still open for the maintainer, as noted earlier: #13667 and #13867 edit the same off lines.

@robi42

robi42 commented Oct 20, 2026

Copy link
Copy Markdown

Hardware confirmation of 048d6fa on a ThinkPad, using the test steps from the review above.

Machine: ThinkPad X1 Carbon Gen 12 (21KCS1XM00), Core Ultra 7 165U. Intel AX211 Bluetooth 8087:0033 on usb 3-10, platform switch tpacpi_bluetooth_sw. Omarchy 4.0.6-1, kernel 7.2.8-9-omarchy, util-linux 2.42.4-1, bluez 5.87-2, quickshell 0.3.2.r7.g2b4501a-1.

Before (installed 4.0.6-1 helper): the bar's off switch had left the radio off the bus, with the same signature as #7936:

rfkill[20909]: block set for type bluetooth
kernel: usb 3-10: USB disconnect, device number 4

Only tpacpi_bluetooth_sw (soft-blocked) remained, bluetoothctl show said No default controller available, and the bar widget was gone. The installed helper's on brought 8087:0033 back on the first try, with no -71 enumeration wedge like the one @stottm hit on another Gen 12.

bash omarchy-bluetooth-power off at 048d6fa: exit 0.

ID TYPE      DEVICE                   SOFT      HARD
 0 bluetooth tpacpi_bluetooth_sw unblocked unblocked
 3 bluetooth hci0                  blocked unblocked
  • bluetoothctl show: Powered: no, controller still registered
  • 8087:0033 still on lsusb, /sys/class/bluetooth/hci0 present
  • journalctl -k: no USB disconnect and no usb 3-10 or hci0 messages since the call
  • systemd-rfkill saved the state under the adapter's own path: pci-0000:00:14.0-usb-0:10:1.0:bluetooth = 1, platform-thinkpad_acpi:bluetooth = 0
  • The bar widget stayed on the bar and showed the off icon (󰂲)

bash omarchy-bluetooth-power on: exit 0. Both switches unblocked, Powered: yes, and no re-enumeration in the kernel log (none was needed, because the device never left the bus). Both saved state files went back to 0.

Not tested: persistence across a reboot, and suspend/resume (the known limitation in the PR description).

Drafted by Claude Opus 5.5 via Claude Code; every value above was read on this machine.

@anandude

Copy link
Copy Markdown
Contributor Author

@robi42 thank you for running it — that's the fourth machine and the third radio vendor with a positive result at the current head (048d6fa).

Coverage now, all on real hardware with the platform switch present:

Machine Radio Platform switch Kernel / utils Result
ThinkPad P15v Gen 3 Intel 8087:0033 tpacpi_bluetooth_sw 7.2.5 only hci0 blocked, adapter stays on the bus
ThinkPad T420 Broadcom 0a5c:217f tpacpi_bluetooth_sw 7.2.5 same, via the bar widget
ThinkPad T14 Gen 2a Realtek 0bda:4852 tpacpi_bluetooth_sw 7.2.5 same, stock 4.0.4 panel
ThinkPad X1 Carbon Gen 12 Intel AX211 8087:0033 tpacpi_bluetooth_sw 7.2.8, util-linux 2.42.4, 4.0.6 same

That covers the three vendors that report the USB-disconnect failure, and two point releases of the stack, so the behaviour does not depend on the util-linux version.

Since @vstoyanov's trace the only change to the block path was cc5d9ba/048d6fa: a platform switch listed with no hci* switch now gets no block at all, and the type-wide block survives only for a successful empty listing. Both were re-reviewed on the head. Nothing else in the diff has moved since d03abf55.

So as far as I can tell nothing is outstanding from the reporters' side — this is ready for a maintainer look.

@omarchybot

Copy link
Copy Markdown
Collaborator

Follow-up at the same head, 048d6fa686d3e356e9a23d05820b001541846d7f. Nothing has changed in the code since my last comment. bin/omarchy-bluetooth-power and test/shell.d/bluetooth-test.sh are also unchanged on quattro (now 087f73d8), so the worker results in that comment still stand.

@robi42's report is useful. It is the first test on real hardware at this head, and it covers the new platform-switch path. Only hci0 was blocked, tpacpi_bluetooth_sw stayed unblocked, there was no USB disconnect, and the widget stayed on the bar. Nothing in it points to a problem with the fix.

It is not yet the confirmation this waits on. @anandude, about the table above: the P15v, T420 and T14 reports tested d03abf55, before the platform-switch path changed. Only the X1 Carbon report tests the current head. For a fix that depends on hardware, the confirmation that settles it comes from the account that reported the bug or from a maintainer. So this is still waiting on @DrakeMorrison (#7936) or @alhasapi (#12599) to run the steps in my last comment, or on a maintainer deciding the reports above are enough.

Who checked it: reviewed by Claude Opus 5.5, with Codex Medium as the second opinion. Codex reread the diff at this head and found no defect. It agreed that neither new comment is the confirmation this waits on, and it pointed out that the coverage table mixes heads. Codex had my earlier comments in front of it, so its agreement is not independent.

@echennells

Copy link
Copy Markdown

Re-tested at the current head 048d6fa (my earlier report above was at d03abf55) on the same ThinkPad T14 Gen 2a (20XLS0A300, Realtek RTL8852AU 0bda:4852 behind tpacpi_bluetooth_sw). Setup: Omarchy 4.0.6-1, kernel 7.2.8-9-omarchy, util-linux 2.42.4, bluez 5.87, stock 4.0.6 panel.

omarchybot's steps above, 5 times, with the helper from its curl command (sha256 matches the commit). Every off exited 0. tpacpi_bluetooth_sw stayed unblocked, hci0 was blocked but still listed, bluetoothctl show said Powered: no, and there was no USB disconnect in the kernel log. rfkill event showed only hci0 changing, never a type-wide block. Every on gave Powered: yes within 11–12 ms. The widget stayed on the bar while off (checked on the first cycle).

The new path (platform switch listed, no hci): I blocked tpacpi_bluetooth_sw by hand so the radio dropped off USB and only the platform switch was listed, then ran off. It exited 0 with no rfkill event at all, so nothing was blocked. After I unblocked the switch, the radio came back and was Powered: yes 1.25 s later.

So the T14 row in the table above now holds for 048d6fa too.

Tested with help from Claude Code; every run was on my machine.

@omarchybot

Copy link
Copy Markdown
Collaborator

Same head, 048d6fa686d3e356e9a23d05820b001541846d7f. Neither touched file has changed on quattro (now 82662dd2), so the worker results from my earlier comment still stand.

@echennells's re-test is the second hardware report at this head, and the first to exercise the platform-switch-only path on a real machine. It replaces the T14 row's older d03abf55 result. Only hci0 changed over five cycles, tpacpi_bluetooth_sw was never blocked, the adapter stayed on the bus, and with only the platform switch listed, off exited 0 without blocking anything. That is what the fix is meant to do.

One behaviour for the maintainer to know about, not a defect: in that platform-only case, off reports success while blocking nothing, so a radio that comes back when the platform switch is unblocked comes back powered on. This is the trade the head makes deliberately (a type-wide block there would trip the platform switch again), and it matches the suspend/resume limitation already noted in the description.

Still waiting on: a run of the steps in my earlier comment by @DrakeMorrison (#7936) or @alhasapi (#12599), or a maintainer deciding that the two current-head reports are enough. Confirmation of a hardware fix has to come from the account that reported the bug or from a maintainer.

Who checked it: reviewed by Claude Opus 5.5, with Codex Medium as the second opinion. Codex found no defect in the diff and agreed that the new report is not the confirmation this waits on. It raised the platform-only behaviour above. My earlier comments were in front of it, so its agreement is not independent.

@luismiguelfm

Copy link
Copy Markdown

Confirming the fix on a ThinkPad T480 at 048d6fa: with the PR, Bluetooth can be toggled off and on from the bar without the adapter disappearing.

Environment

  • Hardware: ThinkPad T480, Intel AX210 Bluetooth (8087:0032, firmware ibt-0041-0041)
  • Kernel: 7.2.8-9-omarchy
  • omarchy: 4.0.6-1
  • quickshell: 0.3.2.r7.g2b4501a-1
  • bluez: 5.87-2

Before (stock 4.0.6)

Turning Bluetooth off from the bar runs rfkill block bluetooth, which also soft-blocks tpacpi_bluetooth_sw. As a result:

  • The radio drops off the USB bus.
  • hci0 disappears from rfkill list and bluetoothctl list.
  • The Bluetooth widget vanishes from the bar, so it can't be turned back on from there.

The only way back I found was Menu → Update → Hardware → Bluetooth.

After (PR head, using the stock /usr/bin/rfkill)

Step tpacpi_bluetooth_sw hci0 Powered is-on
off unblocked blocked no no
off, then USB re-enumeration* unblocked blocked no no
on unblocked unblocked yes yes
toggle → toggle unblocked blocked → unblocked no → yes no → yes
on, then USB re-enumeration* unblocked unblocked yes yes

* Simulated by writing 0 then 1 to /sys/bus/usb/devices/1-7/authorized, which re-registers hci0 the same way resume from S3 does on this machine. systemd-rfkill restored the per-adapter state each time.

Result

With the PR:

  • The adapter stays on the bus while Bluetooth is off.
  • The bar widget stays visible with the "off" icon.
  • The switch works in both directions.

Not tested

  • Persistence across a full reboot.

Resolves the conflict with omacom#16334, which removed the AutoEnable source grep from the end of test/shell.d/bluetooth-test.sh where this branch appends its rfkill tests. The grep stays removed and this branch's tests are kept unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

This branch had started conflicting with quattro, so I merged quattro (7eedd173) into it. The head is now f3d81365d2d5a5b37ce8366bc02dabcbcf71000f. Still waiting on a hardware confirmation from a reporter.

The conflict: #16334 removed the source-text checks from test/shell.d/bluetooth-test.sh, including the AutoEnable=false grep at the end of the file, which is where this branch adds its tests. The merge leaves that grep out, as quattro does, and keeps every test this branch adds. Those tests run the real helper against mock rfkill and bluetoothctl, so they are not the kind #16334 removed. bin/omarchy-bluetooth-power is byte-identical to 048d6fa, and the diff against quattro is the same two files as before. It was a merge, not a rebase, so nothing was force-pushed.

What ran at f3d81365, on a disposable Omarchy VM: ./test/cli: 129 ok, 0 failures. test/shell.d/bluetooth-test.sh: 43 passed (fewer than before because #16334 removed the source checks). test/shell.d/bin-style-test.sh: 2 passed. With quattro's helper put back, the tests fail at "bluetooth blocks only the HCI adapter". With the cc5d9bad helper, they fail at "bluetooth reports a failed listing".

@luismiguelfm's T480 report (Intel AX210, 048d6fa) agrees with the two reports before it at that head. Only hci0 was blocked, the adapter stayed on the bus, and per-adapter state survived a USB re-enumeration. That is the same helper as the current head.

Still waiting on: @DrakeMorrison (#7936) or @alhasapi (#12599) to run the steps from my earlier comment, or a maintainer deciding the current-head reports from @robi42, @echennells and @luismiguelfm are enough. Because the helper hasn't changed, a run at 048d6fa still counts. For the current head, the helper is at https://raw.githubusercontent.com/anandude/omarchy/f3d81365d2d5a5b37ce8366bc02dabcbcf71000f/bin/omarchy-bluetooth-power.

Who checked it: Claude Opus 5.5 did the merge and the review. The second opinion came from Codex Medium and muse-wonder (via pi, thinking high). Both found the resolution correct and agreed that the tests kept are behaviour tests, not source checks. Neither found a defect in the change. They could read my earlier comments on this PR, so their agreement is not independent.

@sl0vvman

sl0vvman commented Nov 4, 2026

Copy link
Copy Markdown

This looks like the right root-cause fix: keeping tpacpi_bluetooth_sw out of the block preserves the adapter on the bus and matches the hardware reports.

One complementary data point. On a ThinkPad T14s Gen2i (AX210, Omarchy 4.0.6-1, kernel 7.2.8-9, bluez 5.87) the bar can avoid the platform switch entirely by using bluetoothctl power off instead of any rfkill block. The adapter stays registered at Powered: no, so the stock widget keeps its icon and can turn it back on; tpacpi_bluetooth_sw stays unblocked and there is no USB disconnect — which is also the trigger in #16210 for the WirePlumber SIGSEGV.

function toggleBluetooth() {
  if (!adapter) {
    Quickshell.execDetached(["omarchy-bluetooth-power", "on"])
    return
  }
  Quickshell.execDetached(["bluetoothctl", "power", adapter.enabled ? "off" : "on"])
}

Trade-off: Powered does not survive reboot, so this is only an option for the UI path, not a replacement for your helper fix. Persistence would need AutoEnable=false or something like #13667.

I have been running that in a cloned widget (https://github.com/sl0vvman/omarchy-bluetooth-stay) across off/on cycles and the adapter stays on D-Bus. Not arguing against the hci-only block — just leaving the alternative and the #16210 angle in case it is useful.

@anandude

anandude commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Status check — I think the gate this was waiting on is now met.

The last review note said it was still waiting on a hardware confirmation from a reporter. Since then the thread has four independent positives, on three radio vendors:

Machine Radio Platform switch Reported by
ThinkPad X1 Carbon Gen 12 Intel AX211 (8087:0033) tpacpi_bluetooth_sw @robi42
ThinkPad T14 Gen 2a Realtek RTL8852AU (0bda:4852) tpacpi_bluetooth_sw @echennells
ThinkPad T480 Intel AX210 (8087:0032) tpacpi_bluetooth_sw @luismiguelfm
ThinkPad T14s Gen2i Intel AX210 tpacpi_bluetooth_sw @sl0vvman

@robi42, @echennells and @luismiguelfm all report the adapter surviving an off/on cycle from the bar, which is the behaviour this was written for. @sl0vvman adds that bluetoothctl power off avoids the platform switch entirely — a fair observation, but a separate change from scoping the block, so I would not fold it in here.

The branch is mergeable against quattro and checks are green. Neither patched file has moved upstream since the worker runs: bin/omarchy-bluetooth-power last changed 2026-08-10 and test/shell.d/bluetooth-test.sh on 2026-10-27 (#16334, which only removed the source-text check). So the earlier verification still applies to the current head.

Not asking for a re-review — just flagging that as far as I can tell nothing is outstanding from the reporter side.

@martincurkovic

Copy link
Copy Markdown

Works perfectly for me. Tested at f3d8136 on a ThinkPad P1 Gen 5, Intel AX211 (8087:0033), tpacpi_bluetooth_sw present, Omarchy 4.5.0-3, kernel 7.2.15, bluez 5.87. omarchy-bluetooth-power off blocked only hci0, tpacpi_bluetooth_sw stayed unblocked, the controller stayed registered at Powered: no, and there was no USB disconnect in the kernel log. on returned it to Powered: yes within a second.

@h45sh

h45sh commented Nov 16, 2026

Copy link
Copy Markdown

Can confirm this on a Dell laptop running Omarchy 4.5.0-3.

Reproduction

  • Hardware has both dell-bluetooth platform switch and hci0 adapter (rfkill list shows both).
  • Turning Bluetooth off from the Omarchy shell runs rfkill block bluetooth (type-wide block), which blocks dell-bluetooth.
  • The Dell embedded controller responds by cutting USB power to the Bluetooth module, causing hci0 to disappear entirely from the system (bluetoothctl reports "No default controller available").
  • Running sudo rfkill unblock bluetooth restores the adapter.

Scoping the block to hci* indexes so the platform switch is spared directly prevents the adapter from dropping off the USB bus.

@omarchybot

Copy link
Copy Markdown
Collaborator

Same head as my last comment, f3d81365d2d5a5b37ce8366bc02dabcbcf71000f. Neither file has changed on quattro since then (now 3b36b9e1), so the worker results from that comment still stand: ./test/cli passes, and the new tests fail against quattro's helper. CI is green.

@martincurkovic's P1 Gen 5 report is the first real-hardware test at this head. Only hci0 was blocked, tpacpi_bluetooth_sw stayed unblocked, the controller stayed at Powered: no with no USB disconnect, and on brought it back. That matches the three reports at 048d6fa, which ran the same helper.

@anandude, about the status check: the T14s Gen2i row in your table is @sl0vvman's widget, which uses bluetoothctl power off and never runs this helper. So it doesn't count as a test of this change. The other three rows are fine. @h45sh's Dell report confirms the bug on a dell-bluetooth machine. It doesn't test the fix, but the fix skips dell-bluetooth the same way it skips tpacpi_bluetooth_sw. @sl0vvman's bluetoothctl approach would be a separate change to the panel. As they say, it doesn't persist across a reboot, so it doesn't replace this one.

Linked: this pull request now also closes #15112 and #16501. Both describe this exact failure on ThinkPads: off soft-blocks tpacpi_bluetooth_sw and hci0 disappears. #16501 also mentions, as a side note, the panel showing off while BlueZ reported Powered: yes. This change doesn't address that. It is the same stale state reported in #15880 and #9665.

Still waiting on a hardware confirmation from someone who opened one of the issues this closes: @DrakeMorrison (#7936), @alhasapi (#12599), @madsclaussen (#15112) or @bhargavenu (#16501). The other option is a maintainer deciding that the four reports above are enough. To test, run this and reply with the output, quoting the full commit f3d81365d2d5a5b37ce8366bc02dabcbcf71000f:

curl -fsSLo /tmp/omarchy-bluetooth-power https://raw.githubusercontent.com/anandude/omarchy/f3d81365d2d5a5b37ce8366bc02dabcbcf71000f/bin/omarchy-bluetooth-power
bash /tmp/omarchy-bluetooth-power off; echo "exit $?"
rfkill list bluetooth; bluetoothctl show | grep Powered; journalctl -k --since "-1min" | grep -i "usb disconnect"
bash /tmp/omarchy-bluetooth-power on

It works if off exits 0, the platform switch stays unblocked, hci0 is blocked but still listed, the adapter shows Powered: no, and there is no USB disconnect. After on, it should show Powered: yes again.

Who checked it: Claude Opus 5.5 reviewed it. The second opinion came from Codex Medium and muse-wonder (via pi, thinking high). Both agreed that none of the new comments is a confirmation from a reporter, and that #15112 and #16501 have the cause this fixes. muse-wonder pointed out the #16501 side note and the T14s row in the table. Neither found a defect in the change. Both could read my earlier comments, so their agreement is not independent.

@h45sh

h45sh commented Nov 17, 2026

Copy link
Copy Markdown

Tested at commit f3d81365d2d5a5b37ce8366bc02dabcbcf71000f on a Dell laptop (dell-bluetooth platform switch present, Omarchy 4.5.0-3, kernel 7.2.15-1-omarchy, bluez 5.88).

Ran the test snippet:

$ curl -fsSLo /tmp/omarchy-bluetooth-power https://raw.githubusercontent.com/anandude/omarchy/f3d81365d2d5a5b37ce8366bc02dabcbcf71000f/bin/omarchy-bluetooth-power
$ bash /tmp/omarchy-bluetooth-power off; echo "exit 0"
exit 0

$ rfkill list bluetooth; bluetoothctl show | grep Powered; journalctl -k --since "-1min" | grep -i "usb disconnect"
2: dell-bluetooth: Bluetooth
	Soft blocked: no
	Hard blocked: no
8: hci0: Bluetooth
	Soft blocked: yes
	Hard blocked: no
	Powered: no

$ bash /tmp/omarchy-bluetooth-power on
$ bluetoothctl show | grep Powered
	Powered: yes

Results:

  • off exited 0.
  • dell-bluetooth stayed unblocked (Soft blocked: no).
  • hci0 was blocked and reported Powered: no, remaining registered on the bus without any USB disconnect.
  • on cleanly brought the adapter back to Powered: yes immediately.

@omarchybot

Copy link
Copy Markdown
Collaborator

Same head as my last comment, f3d81365d2d5a5b37ce8366bc02dabcbcf71000f, and neither file has changed on quattro since.

@h45sh, thanks for running it on the Dell. It is the first test of this change on a dell-bluetooth machine; every earlier report was a ThinkPad with tpacpi_bluetooth_sw. Your output is what the helper should do at this head: only hci0 was blocked, dell-bluetooth stayed unblocked, the adapter stayed listed at Powered: no with no USB disconnect in the log, and on brought it back. With your earlier report of the bug on the same machine, that makes a before and after.

One line doesn't show what it says: the command reads echo "exit 0" rather than echo "exit $?", so it prints exit 0 whatever the helper returned. If you run bash /tmp/omarchy-bluetooth-power off; echo "exit $?" once more and post that line, the gap is closed. The rfkill state above doesn't depend on it.

Still waiting on the same thing as before: a confirmation, using the snippet in my last comment, from someone who opened one of the issues this closes (#7936, #12599, #15112 or #16501), or a maintainer deciding that the five hardware reports so far are enough. Your test counts toward that decision, but it isn't one of those confirmations, since it doesn't come from one of those issues' openers.

Who checked it: Claude Opus 5.5 read the new report against the helper at this head. The second opinion came from Codex Medium and muse-wonder (via pi, thinking high). Both found the output consistent with the change, both flagged the exit 0 line, and neither found a defect. I pointed both at the snippet's original line, so their agreement on that point is not independent.

@h45sh

h45sh commented Nov 17, 2026

Copy link
Copy Markdown

Here is the snippet with literal $? (without subshell expansion):

$ bash /tmp/omarchy-bluetooth-power off; echo "exit $?"
exit 0

Confirmed that off cleanly exits 0.

@thomasgraichen

Copy link
Copy Markdown

Tested on a ThinkPad X1 Carbon 7th, Omarchy 4.5.0-3, kernel 7.2.15-4-omarchy, Intel 9460/9560 Bluetooth (8087:0aaa, btusb, firmware intel/ibt-17-16-1.sfi).

Before (stock 4.5.0-3 helper): turning Bluetooth off from the panel soft-blocks tpacpi_bluetooth_sw, the module drops off USB (usb 1-10: USB disconnect), and the panel shows no adapter and can't turn it back on. Only rfkill unblock bluetooth (Menu → Update → Hardware → Bluetooth) recovers it. Once I also saw Bluetooth: hci0: Error when powering off device on rfkill (-71).

With this PR at f3d81365d2d5a5b37ce8366bc02dabcbcf71000f, using the temporary-helper instructions:

exit 0
0: tpacpi_bluetooth_sw: Bluetooth
	Soft blocked: no
	Hard blocked: no
2: hci0: Bluetooth
	Soft blocked: yes
	Hard blocked: no
Controller XX:XX:XX:XX:XX:XX omarchy-thinkpad [default]
	Powered: no
(end usb disconnect grep)
on exit 0
	Powered: yes

off exits 0, the platform switch stays unblocked, hci0 is blocked but still listed at Powered: no, there's no USB disconnect, and on restores Powered: yes.

@omarchybot

Copy link
Copy Markdown
Collaborator

#20378 already keeps the platform switch unblocked when an HCI adapter is listed. Thanks @thomasgraichen for testing that case at this PR's head on the X1 Carbon against stock 4.5.0-3. The remaining difference is in the fallback. Current quattro still attempts a type-wide block if the listing fails or contains only a platform switch. This PR stops on a listing error and leaves a lone platform switch untouched. #12585 handles recovery after detachment.

GPT-6.2 Sol in Codex (high effort) compared the diffs and checked the passing GitHub checks at this head. Opus 5.5 High and muse-wonder via pi, thinking high agreed on the fallback behavior. Their independence is unverified. The branch conflicts with quattro in the helper and its tests. The maintainer can decide whether to carry the fallback changes forward, including whether off should report success when only the platform switch is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment