Skip to content

Keep bluetooth bar icon visible after adapter disappears - #12241

Closed
RushiChaganti wants to merge 1 commit into
omacom:quattrofrom
RushiChaganti:quattro
Closed

RushiChaganti wants to merge 1 commit into
omacom:quattrofrom
RushiChaganti:quattro

Conversation

@RushiChaganti

@RushiChaganti RushiChaganti commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

The adapter disappears when Bluetooth is turned off, so this PR keeps the Bluetooth icon and toggle visible even when the adapter is temporarily unavailable.

Summary

  • On some drivers, rfkill blocking removes the BlueZ adapter D-Bus object, causing Bluetooth.defaultAdapter to become null.
  • This previously hid the Bluetooth icon and toggle, leaving no UI way to turn Bluetooth back on.
  • Added adapterEverSeen to keep the icon, toggle, and power action available after an adapter has been detected, treating a null adapter as the Bluetooth off state.

Test Plan

  • Run ./test/shell
  • Toggle Bluetooth off/on from the bar and verify the icon and switch remain visible and functional.

@llstrk

llstrk commented Sep 25, 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.

Verified: within a running shell, the change does what it describes. Once a widget has seen an adapter, a later null adapter keeps the bar icon, panel and power switch visible as "Turned Off", and the toggle requests omarchy-bluetooth-power on. Machines that never report an adapter still hide the widget, and present-adapter states (on, off, connected) render as before. Every other adapter use in Panel.qml stays null-guarded, and no new null dereference was found.

One gap remains in the scenario the PR targets, plus a smaller side effect.

The latch resets whenever the widget is recreated, including after a reboot with Bluetooth off

adapterEverSeen is per-instance memory that starts false. On hardware where the block removes the adapter, the off state is meant to persist: bin/omarchy-bluetooth-power uses the rfkill block because systemd-rfkill restores it across reboots. A widget created while the adapter is absent never sees one, so it hides again:

Affected hardware, Bluetooth turned off from the bar

                                   base         head
same shell session, adapter gone   hidden       visible, "Turned Off"   <- fixed
reboot / re-login (block restored) hidden       hidden                  <- unchanged
shell restart                      hidden       hidden                  <- unchanged
bar layout/orientation change      hidden       hidden                  <- unchanged
monitor connected while off        hidden       hidden on that monitor

A widget created while an adapter is present does latch at creation. The reset only matters when the adapter is absent at that moment.

Impact: after a reboot with Bluetooth off, the PR's stated problem ("no UI way to turn Bluetooth back on") returns on the hardware it targets. The IPC toggleBluetooth path also returns early in that state. The menu's hardware Bluetooth restart entry still unblocks it, so this is a gap rather than a lockout.

Suggested change: derive "show the off state" from a signal that survives restarts, such as the presence of a Bluetooth rfkill switch (it stays registered while blocked; behavior on machines without a Bluetooth module would need checking). Alternatively, state in the PR and the code comment that the fix covers only the current session.

A physically removed adapter now shows as "Turned Off"

Once latched, every null adapter reads as off, including an unplugged USB dongle or a stopped bluetooth.service. The widget stays with "Turned Off" and a clickable switch. The helper then finds no controller and exits with an error, which execDetached discards, so nothing visible happens. Before the PR, the widget disappeared in these cases.

Impact: a misleading status and a switch that cannot succeed, lasting until the widget is recreated. Lower impact than the first finding.

Suggested change: where possible, distinguish "no Bluetooth hardware" from "rfkill-disabled controller" (the rfkill signal above could serve both), or reset the latch when an enable attempt fails.

Optional test improvement: the edited assertion in test/shell.d/bluetooth-test.sh only re-pins the toggle's ternary (adapter && adapter.enabled). It fails on base only because of that prefix, and it would still pass if the latch, the new visible binding or the new early-return guard were removed. Matching source assertions for visible: adapter !== null || adapterEverSeen and the toggle guard would cover the actual change.

Comment wording: the new comment says BlueZ removes the adapter's D-Bus object while rfkill holds it blocked. BlueZ keeps soft-blocked adapters and reports them as powered off. The object disappears when the block powers the module off and the kernel drops the controller, after which BlueZ unregisters it. Wording along those lines would be more accurate.


Review information

Test scope: source review of the pinned head against the merge-base, including bin/omarchy-bluetooth-power, the bar widget lifecycle, Quickshell v0.3.1 Bluetooth sources and BlueZ adapter/rfkill handling. The QML latch declarations were run in an isolated Qt 6.11.2 engine (synthetic adapter object). The Node block of bluetooth-test.sh was run in isolation through a Qt JavaScript engine shim rather than Node: 34/34 assertions passed on both base and head with their own test, and each version's test failed on the other at the toggle assertion. No Bluetooth hardware, rfkill, BlueZ or desktop session was used, so which machines drop the adapter on block, and whether on restores it in time, were not verified on hardware.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, Opus 5.5 Medium editorial check.

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

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for this, @RushiChaganti. I read it at 8e198d1 against quattro, beside the seven other open pull requests that fix the same disappearing widget (#13523, #12599, #12494): #12585, #13204, #13655, #13806, #11252, #10749 and #10003. Nothing was run on a worker. This was a source review, and it stopped at choosing between the fixes.

The problem is real, and this fixes it for the current session only. Once this widget instance has seen an adapter, a null adapter keeps the icon, the switch and the "on" path, as described. But adapterEverSeen (shell/plugins/panels/bluetooth/Panel.qml:31) starts out false on every new instance, and bin/omarchy-bluetooth-power deliberately turns Bluetooth off with an rfkill block because systemd-rfkill restores that block at boot. On the hardware this targets, turning Bluetooth off and then rebooting, restarting the shell or recreating the widget starts with no adapter and no latch. The widget stays hidden, and toggleBluetooth() (Panel.qml:644) returns early, IPC path included, so the original problem comes back. The latch also never clears, so an unplugged dongle or a stopped bluetooth.service reads as "Turned Off" with a switch that cannot succeed.

#12585 is the fix I'd put forward. It asks rfkill whether the radio is soft-blocked whenever BlueZ has no adapter, at startup as well as on every change. That covers a persisted block after a reboot, and it still hides the widget on a machine with no Bluetooth. #13204 is the smaller alternative, but it keys on whether a Bluetooth switch exists rather than whether it is blocked, so a stopped bluetooth.service also shows as "off". Both are ahead of this pull request on the reboot case.

Second opinion: Codex at medium effort ranked them independently of my answer, but it can read this session, so its independence is not guaranteed. It reached the same order, #12585 first and #13204 second, and found the same reboot gap in this one. It added that #10749 leaves visible: adapter !== null in place and so does not keep the widget on the bar, and that #13806 shares this pull request's latch.

Next step: the maintainer chooses between the competing fixes, so this is waiting on them.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this, @RushiChaganti. #12585 fixes the same problem and also handles a case this one misses, as the review above explains, so this is closed in favour of it. If it does not cover your case, please say so there.

Closed at the maintainer's request. The review comment above has the details; it was done by Claude Opus 5.5 with Codex Medium as a second opinion, whose agreement is not independent.

@omarchybot omarchybot closed this Oct 3, 2026
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.

3 participants