Skip to content

Let the Bluetooth toggle turn a radio back on after its adapter leaves D-Bus - #13555

Closed
manuaudio wants to merge 1 commit into
omacom:quattrofrom
manuaudio:fix/bluetooth-toggle-without-adapter
Closed

manuaudio wants to merge 1 commit into
omacom:quattrofrom
manuaudio:fix/bluetooth-toggle-without-adapter

Conversation

@manuaudio

Copy link
Copy Markdown
Contributor

Fixes #13523.

Some Bluetooth adapters disappear from BlueZ entirely while they're rfkill-blocked. On ThinkPads, for example, the platform switch cuts power to the USB radio. When that happens Bluetooth.defaultAdapter goes null, and the panel treated that as "no Bluetooth hardware":

  • the bar widget hid itself (visible: adapter !== null)
  • toggleBluetooth() returned early on !adapter, so right-click, the panel switch, the b key and the omarchy.bluetooth toggleBluetooth IPC all did nothing

So once Bluetooth was turned off from the bar, the only way to turn it back on was omarchy-bluetooth-power on in a terminal.

Change

The rfkill switch outlives the adapter, so the panel now follows it. A single rfkill event process reports every switch when it starts and each change after that, with no polling. Model.withRfkillEvent() folds those lines into a map of Bluetooth switches, and a blocked one makes the panel treat Bluetooth as off rather than absent:

  • available (adapter present, or a Bluetooth switch blocked) drives the widget's visibility, the switch and the "No adapter" texts
  • poweredOn (adapter present and enabled) drives the icon, the switch state and the toggle direction, so with no adapter the toggle asks omarchy-bluetooth-power on

Machines with no Bluetooth radio at all still hide the widget as before.

Testing

  • test/shell.d/bluetooth-test.sh: new assertions for the rfkill event parser (Wi-Fi switches ignored, a platform switch still counting after the adapter's own switch is removed, hard blocks, unblocking, junk lines) and for the panel wiring. The old toggle assertion now fails against the previous code.
  • ./test/shell: the 7 failures on this branch are identical to the 7 on quattro without the change (cache, kernel headers, browser focus, portal fixture, omasnap, the ShellIpc registration check). They're environment-related or pre-existing.
  • Live, on Omarchy 4.0.0.alpha with an Intel adapter, running the patched panel in the session shell. This adapter stays on D-Bus while blocked, so I reproduced the reporter's state by blocking the radio and masking bluetooth.service:
    • Stock shell: the Bluetooth icon vanished from the bar and the toggleBluetooth IPC left the radio blocked.
    • Patched shell: the bar showed the off icon, and the panel opened with "Turned off", the switch and "Turn Bluetooth on to scan". Both the b key and the IPC unblocked the radio.
    • Normal path, adapter present (patched): on → off → on works, and the icon follows each change.

I haven't tested on ThinkPad hardware with a platform switch myself. A confirmation from the reporter would be welcome.

🤖 Generated with Claude Code

…s D-Bus

Some adapters disappear from BlueZ entirely while blocked, such as ThinkPad radios whose platform switch cuts their power. Bluetooth.defaultAdapter then goes null, and the panel treated that as having no Bluetooth at all: the bar icon hid itself and toggleBluetooth returned early, so Bluetooth turned off from the bar could only be turned back on from a terminal. The panel now follows the rfkill switches through `rfkill event`, which outlive the adapter, and treats a blocked Bluetooth switch as Bluetooth that is off rather than absent.

Fixes omacom#13523

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

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate. #12241 and #12585 (which fixes the earlier report #12494) already fix this same bug, where turning Bluetooth off makes the adapter vanish and leaves no way back on from the bar, and both predate this PR. I missed them when checking for prior work. Sorry for the noise.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bluetooth bar toggle can't turn Bluetooth back on once it's off (adapter becomes null)

1 participant