Skip to content

Block only hci* rfkill switches when turning Bluetooth off - #20378

Merged
dhh merged 1 commit into
quattrofrom
fix/bluetooth-rfkill-detached
Nov 27, 2026
Merged

dhh merged 1 commit into
quattrofrom
fix/bluetooth-rfkill-detached

Conversation

@dhh

@dhh dhh commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What changes

On laptops with a platform ACPI Bluetooth rfkill switch (such as ThinkPad's tpacpi_bluetooth_sw), rfkill block bluetooth blocks both the controller switch (hci0) and the platform switch. Blocking the platform switch cuts power to the internal USB port mid-shutdown, causing kernel timeout errors (Opcode 0x2039 failed: -110, USB disconnect), dropping hci0 from BlueZ so the Bluetooth bar icon disappears completely, and forcing a ~2.8s USB re-enumeration and firmware reload when turning Bluetooth back on.

  • bin/omarchy-bluetooth-power: When turning Bluetooth off, block only the hci* rfkill IDs from rfkill --raw --noheadings --output ID,DEVICE list bluetooth (falling back to rfkill block bluetooth if none are listed). Blocking hci* keeps the controller attached in BlueZ (Powered: no / PowerState: off-blocked), still persists across reboots via systemd-rfkill, eliminates the USB disconnect errors, and drops turn-on latency from ~2.8s to ~0.25s. power_on still runs rfkill unblock bluetooth so any already-blocked platform switch gets cleared.
  • test/shell.d/bluetooth-test.sh: Add tests confirming off blocks only hci* IDs when a platform switch is present, and on still unblocks all Bluetooth rfkill switches.

Verification

  • bash test/shell.d/bluetooth-test.sh: all checks pass, including the new platform-switch tests.
  • shellcheck -S warning bin/omarchy-bluetooth-power: clean.
  • Verified live on a ThinkPad (tpacpi_bluetooth_sw + hci0):
    • omarchy-bluetooth-power off leaves tpacpi_bluetooth_sw unblocked and soft-blocks hci0; omarchy-bluetooth status reports Power: off with Controller: dhh-tp, the bar widget stays visible with the off glyph, /var/lib/systemd/rfkill/pci-0000:00:14.0-usb-0:10:1.0:bluetooth saves 1, and dmesg logs zero errors.
    • omarchy-bluetooth-power on restores Power: on in 0.25s with no USB re-enumeration or firmware reload.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no new actionable issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Bluetooth shutdown now blocks only listed hci* switches, leaving platform switches alone.

  • Bluetooth off blocks controller switches without blocking separate platform switches.

Reviews (5) · Last reviewed commit: "Block only hci* rfkill switches when tur..." · Reviewed by Greptile

Comment thread bin/omarchy-bluetooth Resolved
@omarchybot omarchybot added the bug Something isn't working label Nov 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Codex High compared this head with the earlier Bluetooth fixes. Opus 5.5 High and muse-wonder via pi, thinking high also favored carrying the widget fix in #12585; the second review's independence is not guaranteed. That older implementation preserves visibility while rfkill answers and follows switch-removal events while BlueZ already has no adapter. These are competing implementations, so both PRs remain open for the maintainer's choice.

I queued this PR's detached-controller CLI status, auto-power-on before scanning or device-name lookup, and CLI regression coverage to be folded into #12585, crediting @dhh. No worker tests were run for this PR because it is being left behind the competing fix; the combined change must be verified in that PR's session. This head's CI checks pass. Waiting on the maintainer.

omarchybot added a commit to selfcrypto/omarchy that referenced this pull request Nov 27, 2026
Carry the CLI recovery from omacom#20378 into the widget fix. A blocked platform radio can have no BlueZ controller, so status and auto-power operations consult the same soft-block query as the panel. Power up before resolving device names because BlueZ cannot resolve them while the controller is absent. Keep the existing power deadline.

Co-Authored-By: David Heinemeier Hansson <david@hey.com>
Co-Authored-By: GPT-6 <noreply@openai.com>
Co-Authored-By: Opus 5.5 High <noreply@anthropic.com>
@dhh
dhh force-pushed the fix/bluetooth-rfkill-detached branch from 6bb9de7 to 255ac57 Compare November 27, 2026 09:33
@dhh dhh changed the title Keep Bluetooth widget and CLI working when rfkill disconnects the adapter Block only hci* rfkill switches when turning Bluetooth off Nov 27, 2026
@omarchybot omarchybot added the compatibility Make Omarchy work better on everything! label Nov 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Codex High compared 255ac57ece6d06fd2d0bf5f5ccbc3303197110ae with the earlier #12753. Both scope Bluetooth shutdown to HCI switches. The earlier implementation also distinguishes a failed rfkill query or a platform-only listing from a successful empty listing; this head falls back to rfkill block bluetooth in all three cases. No material improvement here needs folding into the earlier PR.

Opus 5.5 High and muse-wonder via pi, thinking high also favored carrying the fix in #12753; their independence is not guaranteed. They disagreed on whether the fallback differences permit duplicate closure, so both PRs remain open for the maintainer’s choice. #12585 addresses recovery when a controller is already detached and remains complementary.

This comparison checked the two diffs, current Bluetooth callers, and the base-branch rules. CI passes on this head. No worker tests or hardware verification were run because this is being left behind the competing fix; that comparison does not establish #12753’s readiness. Waiting on the maintainer.

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

Labels

bug Something isn't working compatibility Make Omarchy work better on everything!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants