Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
This change was written mostly by an AI and I wasn't involved deeply in technical details of it, but this I am writing myself from my own understanding of it. This PR is opened because I have a problem with my own quickshell so called "Shell" for linux, specifically with people on PC (not laptops) without a bluetooth module, who use bluetooth dongles. What happens is that on startup, quickshell checks "ONCE" whether bluetooth is available on the machine. But with bluetooth dongles, users regularly plug them in or unplug them while the quickshell process is running. And the problem then becomes that quickshell does not discover that bluetooth is available and therefore using it for in-shell panels doesn't properly work, as in my case the visible state of the panel is tied to whether bluetooth is available. So this change adds a monitor that watches on this change in bluetooth availability, essentially whether a bluetooth dongle had been plugged in during runtime. This allows to enable bluetooth if it "suddenly" becomes available on the system without having to restart the process.
Details and descisions
AI-written notes (Claude was used for the change)
I used QDBusServiceWatcher because the mpris watcher already does it this way, so it matches the rest of the codebase. I didn't want to poll or add a new pattern.
The watcher is set up before the first setInterface call. If BlueZ shows up in the small gap between the two, setInterface just runs twice. That's harmless: setInterface replaces the old interface, and onInterfacesAdded already handles paths it has seen before.
When BlueZ comes back I call setInterface again instead of adding separate reconnect code. That reuses fetchInitialObjects and the normal adapter/device tracking, so a restart goes through the same path as a normal start.
When BlueZ goes away it doesn't send InterfacesRemoved for its objects (a crash certainly won't), so I drop everything myself. Devices come off their adapters first, then both lists are emptied and defaultAdapter is updated to null. Only after that are the objects deleted, so nothing in QML is left with an adapter that no longer exists. When BlueZ returns, adapters and devices are created as new objects instead of reusing the old ones.
I removed the early return after the failed setInterface, since the watcher now takes care of BlueZ starting later. The log message changed to match.
Open concerns
AI-written notes
I tested against a fake BlueZ (one adapter, no devices) on a private D-Bus daemon used as the system bus. It covered starting late, stopping, and starting again. I didn't test a real dongle hotplug or a restart with devices connected. In that case the device objects are deleted and recreated, so QML holding a device reference gets null and then a new object. I think that's correct, but say so if you'd rather keep the objects.
After BlueZ stops, the object manager keeps its old interface until BlueZ comes back and replaces it. It doesn't receive anything in the meantime, so I left it alone instead of adding a way to clear it.