Skip to content

feat(linux): Show all connected AirPods battery status in tray tooltip (#670)#676

Open
QuantumBreakz wants to merge 1 commit into
librepods-org:mainfrom
QuantumBreakz:feat/670-linux-tray-multiple-devices
Open

feat(linux): Show all connected AirPods battery status in tray tooltip (#670)#676
QuantumBreakz wants to merge 1 commit into
librepods-org:mainfrom
QuantumBreakz:feat/670-linux-tray-multiple-devices

Conversation

@QuantumBreakz

Copy link
Copy Markdown

Summary

Closes #670

When multiple AirPods are connected on Linux, the tray application would overwrite the tooltip with whichever device sent the latest update, meaning only one device status was visible.

This PR gives TrayIconManager a per-device registry keyed by Bluetooth MAC address, showing all connected devices' battery states in a multi-line list on hover.


Changes

1. TrayIconManager (trayiconmanager.h / trayiconmanager.cpp)

  • Replaced the single updateBatteryStatus(status) API with a per-device registry (QList<DeviceEntry>) keyed by Bluetooth address.
  • Added functions:
    • updateDeviceBattery(key, name, status) – registers or updates a device.
    • updateDeviceName(key, name) – refreshes a device's display label.
    • setActiveDevice(key) – decides which device's battery drives the numerical percentage icon.
    • removeDevice(key) – removes a device on disconnect.
  • Render tooltip:
    • 0 devices: empty.
    • 1 device: keeps original format (Battery Status: ...) so single-AirPod users notice no change.
    • 2+ devices: multi-line tooltip (<name>: <status>), active device listed first.

2. main.cpp Wiring

  • Replaced direct batteryStatusChanged slot with a lambda using the new per-device API.
  • Wired deviceNameChanged to update the label in the registry when AACP metadata arrives.
  • Reset device info if connecting to a device with a different address.
  • Pre-populated the device name with the BlueZ device name right after setting the MAC address to show a label before AACP metadata is received.
  • On disconnect, call trayManager->removeDevice() instead of resetting the whole tray icon.

3. BLE Override Guard

  • Broadcast packets are anonymized, and matching the stored IRK could trigger updates for a paired-but-not-connected device, overwriting the live connected device's battery status.
  • Added a guard in bleDeviceFound to ignore BLE broadcasts when a live L2CAP/AACP connection is active.

Constraints

  • The application currently only supports one live AACP/L2CAP socket at a time. The non-active device will display its last-known values, not live-updating ones, as supporting multiple active sockets is a much larger refactoring outside the scope of this issue.
  • The tooltip lists all connected devices' names and batteries rather than rendering multiple circles in the tray icon.

Testing & Verification

  • Compile verified via a clean CMake/Ninja build in a Qt6 container.
  • Verification steps for reviewers with multiple devices:
    1. Connect two sets of AirPods.
    2. Hover over the tray icon.
    3. The tooltip should display the names and battery status of both devices.

…ltip (librepods-org#670)

- Add per-device registry (QList) to TrayIconManager keyed by bluetooth address
- Implement updateDeviceBattery, updateDeviceName, setActiveDevice, removeDevice
- Update tooltip rendering to show all connected devices (one per line, active device first)
- Update main.cpp connection hooks to register and update device name and battery dynamically
- Clean up device from tray registry on disconnect
- Ignore anonymized BLE proximity broadcasts while an active AACP connection is running to prevent battery overwrite
@QuantumBreakz

Copy link
Copy Markdown
Author

Hey @kavishdevar 👋

This PR addresses the multiple-device tray status issue #670.

Could you please self-assign as reviewer/assignee when you have a moment? Since the PR is from a fork, GitHub restricts external permissions for setting these directly.

Thanks! 🙏

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.

[Linux] Tray application can only show status of one device when multiple devices are connected

2 participants