linux: show battery for all connected AirPods in the tray#674
Open
bissamiftikhar wants to merge 2 commits into
Open
linux: show battery for all connected AirPods in the tray#674bissamiftikhar wants to merge 2 commits into
bissamiftikhar wants to merge 2 commits into
Conversation
Replace the single global tooltip string with a small per-device registry keyed by Bluetooth address. Each entry stores the device's last known name and formatted battery status. The tooltip lists every known device (active device first); with a single device the tooltip format is unchanged. The icon percentage is driven only by the active device, and resetTrayIcon() now clears the registry as well.
Previously the tray tracked a single global battery status, so with two AirPods connected the most recent update simply overwrote the other device's status, and BLE broadcasts matching the stored IRK could override the AACP-connected device's state with data from a different (paired but not connected) device. - Battery updates are now recorded per device (keyed by Bluetooth address) and the tooltip lists every known device, active device first. A device's entry is only removed when that device disconnects. - Switching the AACP connection to another device resets DeviceInfo so the new device doesn't inherit the previous device's name/battery; the previous device's last known status stays visible in the tray. - BLE broadcasts are ignored while an AACP connection is up: the live connection is authoritative, and an IRK-matched broadcast may belong to another paired device. - The BlueZ device name is used as the tray label until the AACP metadata packet provides the canonical name. Fixes librepods-org#670
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.
Fixes #670
Problem
The tray tracked battery as a single global string. With two AirPods connected at the same time, whichever device updated last simply overwrote the other one in the tooltip, and on top of that
bleDeviceFound()let a BLE proximity broadcast that matches the stored IRK override the state of the device the app is actually connected to — the broadcast is anonymized, so it may well belong to a different paired device sitting in its case nearby. That's the "AirPods Pro 2 superseding the AirPods 4" behavior described in the issue.What changed
TrayIconManagernow keeps a small per-device registry (keyed by Bluetooth address) instead of one status string:updateDeviceBattery(key, name, status)upserts a device's entry and re-renders the tooltip.main.cppwiring:bluezDeviceDisconnectedfires per device) remove exactly that device's entry.DeviceInfois reset so the new device doesn't inherit the previous device's name/battery in the UI. The previous device's last-known status stays visible in the tray until it actually disconnects.Result
Hovering the tray icon with two connected devices now shows e.g.:
With one device connected the tooltip is identical to current behavior (
Battery Status: Left: …).Notes / limitations
cmake -G Ninja). I'd appreciate a hands-on test from someone with two sets of AirPods — @GarrettGR's setup from the issue is exactly the scenario this targets.