Skip to content

linux-rust: COSMIC support, panel applet, UI redesign, crash and audio fixes - #934

Open
satyakommula96 wants to merge 12 commits into
librepods-org:linux/rustfrom
satyakommula96:linux/rust
Open

satyakommula96 wants to merge 12 commits into
librepods-org:linux/rustfrom
satyakommula96:linux/rust

Conversation

@satyakommula96

Copy link
Copy Markdown

Summary

This makes the Rust Linux app work well on Pop!_OS / COSMIC (and other desktops), adds a native COSMIC panel applet, redesigns the window, and fixes a number of bugs, including several crashes found by new tests. Everything was tested on Pop!_OS 24.04 (COSMIC, Wayland, BlueZ 5.72, PipeWire) with AirPods Pro 2.

The PR is large; the commits are grouped by area and I'm happy to split it into smaller PRs if that's easier to review. (Much of the line count is the new applet's Cargo.lock.)

Fixes

Crashes (release builds use panic = "abort", so each of these took down the whole app):

Audio

Battery and controls

Other

  • Proximity keys (IRK / encryption key) are never logged ([Linux/rust] Don't log AirPods proximity keys #897 by smoothxhale; also redacted from raw packet logs and Debug).
  • Wayland app_id now matches the desktop file, so docks show the right icon; window icon embedded.
  • The "System" theme follows the XDG portal color scheme directly (iced reset it to light when a window opened on Wayland).
  • Launching the app again no longer truncates the running instance's log.

Features

  • COSMIC panel applet (linux-rust/cosmic-applet, libcosmic): battery %, popup with battery, noise control, conversation awareness, Connect, Open and Quit. The tray icon hides while the applet runs.
  • Local IPC + CLI over the single-instance socket: librepods --status / --watch (JSON, for status bars, Quickshell Support #732), --listening-mode off|anc|transparency|adaptive|cycle (bind to a shortcut, [Linux] global shortcut to change noise control nodes #155), --connect, --quit.
  • Single instance: launching again opens the existing window.
  • Connect button (e.g. after using the AirPods with an iPhone), in the window, tray and applet, with a per-device choice when several AirPods are saved.
  • Pairing helper that pairs over BR/EDR, avoiding the LE "Find My" identity that makes pairing fail on Linux.
  • Low-battery notifications at 20% and 10% (with hysteresis), toggle in Settings.
  • Start on login (XDG autostart; Flatpak-aware), log file in $XDG_STATE_HOME/librepods/librepods.log when not started from a terminal.
  • LE advertisement monitor restarts after Bluetooth is toggled or the system resumes.
  • Last live case battery is remembered across restarts and shown with its age.

UI

Redesigned window, with the layout inspired by the MousePods desktop app by Matteo Gaudioso (https://github.com/starman-tech/mousepods); no MousePods code is used. Sidebar with device list and live battery, overview card with battery rings, segmented noise-control buttons, grouped settings cards, and a responsive layout for narrow (tiled) windows.

Packaging and CI

  • AppStream metadata shipped in the AppImage (validated by appimagetool); cleaned-up metainfo.
  • AppImage built on Ubuntu 22.04 (glibc 2.35) so it runs on 22.04+; CI fails if a binary needs a newer glibc. ubuntu-latest had moved to 26.04 (glibc 2.43), and that AppImage failed on 24.04.
  • AppImage repacked with gzip so AppImageLauncher 2.x can open it (the maintained appimagetool only supports zstd); CI checks the compression.
  • Actions bumped, cargo test --locked for the app and the applet, applet built and published, superseded runs cancelled.
  • Dependencies bumped (including aes from 0.9.0-rc.4 to 0.9.4, checked against the Bluetooth spec test vector, and imageproc 0.27).

Tests

2 → 57 unit tests (52 app, 5 applet): real packet bytes, Bluetooth Core Spec vectors for the RPA hash, FIPS-197 for AES, the packet handler end to end, the IPC protocol and the app/applet JSON contract, low-battery rules, single instance, and UI smoke tests for every page in both layouts.

Notes for testing

  • ControllerMode = bredr may still be needed to pair if the pairing helper doesn't succeed on a given adapter; the helper's error message says so.
  • BlueZ Experimental = true is needed for the LE advertisement monitor (case battery from broadcasts); the app logs how to enable it.
  • Building the applet needs libxkbcommon-dev.

Make the Rust app work well on Pop!_OS / COSMIC (and other desktops),
add a native COSMIC panel applet, and fix several bugs found while
testing with AirPods Pro 2.

Startup and Bluetooth
- Don't crash when Bluetooth is off or rfkill-blocked (COSMIC's toggle);
  wait for a powered adapter instead of forcing it on.
- Don't abort when no StatusNotifier host is available.
- Restart the LE advertisement monitor after Bluetooth is toggled or the
  system resumes; skip bad events instead of stopping the monitor; log
  an actionable hint when BlueZ Experimental is disabled.

Desktop integration
- Set the Wayland app_id to match the .desktop file, embed the window
  icon, and improve the desktop entry.
- Add a "System" theme that follows the desktop light/dark preference.
- Add a "Start on login" setting (XDG autostart; Flatpak-aware).
- Keep a single instance; a second launch opens the existing window.
- Write logs to $XDG_STATE_HOME/librepods/librepods.log when not
  started from a terminal.
- Create config/data directories at startup (librepods-org#633).
- Tray: left click opens the window (librepods-org#636), readable outlined text,
  "100" no longer clipped, radio state updated on selection (librepods-org#635).
- Add `just install`, `install-cosmic-applet` and `uninstall`.

IPC, CLI and COSMIC applet
- Local socket IPC: status subscription and control commands.
- CLI: --listening-mode off|anc|transparency|adaptive|cycle (librepods-org#155),
  --status and --watch for status bars (librepods-org#732).
- New cosmic-applet crate: panel button with battery %, popup with
  battery, noise control, conversation awareness and "Open LibrePods".
  The tray icon is hidden while the applet is running.

Audio
- Always resolve the PipeWire card afresh and wait for it to appear;
  the cached index went stale on reconnect.
- When A2DP is missing, ask BlueZ to connect the profile (its own setup
  can fail with EBUSY racing the AAP connection) instead of restarting
  WirePlumber, which interrupted all audio.
- Don't re-switch an already active A2DP profile (from librepods-org#766).
- Fix a deadlock in the playback listener with a second device
  connected (from librepods-org#896) and don't hold the AACP state lock while
  sending (from librepods-org#775).

Battery and controls
- Ignore "unknown" battery sentinels (level > 100, or 0 while
  disconnected) and merge readings per component instead of replacing
  them (librepods-org#422); show a bud resting in the case as "in case".
- Apply AirPods setting changes to the current state instead of a stale
  snapshot, fixing "Adaptive" displaying as "Off" (librepods-org#423).

Security
- Never log proximity keys (IRK / encryption key) (from librepods-org#897).

Dependencies
- Bump tokio, clap, dbus, env_logger, futures, ksni, log, serde,
  serde_json and uuid; move aes off 0.9.0-rc.4 to 0.9.4; imageproc 0.27.
- Add tests for the RPA hash (Bluetooth Core Spec vector) and tray icon
  rendering.
- Bump actions/checkout to v7, actions/upload-artifact to v7 and
  softprops/action-gh-release to v3 (Node 24 runtime).
- Replace actions/cache with Swatinem/rust-cache, covering both crates.
- Download appimagetool from AppImage/appimagetool (AppImageKit is
  deprecated).
- Fix the paths filter, which referenced a non-existent workflow file.
- Also run on pull requests to linux/rust.
- Run cargo test and build with --locked.
- Build the COSMIC applet (adds libxkbcommon-dev) and publish it as an
  artifact and release asset.
ubuntu-latest now resolves to Ubuntu 26.04 (glibc 2.43), so the AppImage
and binaries failed to start on Ubuntu/Pop!_OS 24.04 with
"version `GLIBC_2.43' not found". Pin the build to ubuntu-22.04
(glibc 2.35) and fail the job if a binary requires a newer glibc.
Group runs by workflow and ref so a new push cancels the older run that
is still in progress. Release tag builds are never cancelled.
Ubuntu 22.04 doesn't package just, so apt-get failed. Install a prebuilt
binary instead.
mktemp -d creates the AppDir with mode 0700. Newer appimagetool rejects
that because other users would get "Permission denied" running the
AppImage. Set it to 0755.
- Install the metainfo as usr/share/metainfo/me.kavishdevar.librepods.appdata.xml,
  where appimagetool looks for it and validates it with appstreamcli.
- Name the AppImage's desktop file me.kavishdevar.librepods.desktop so it
  matches the metainfo <launchable> and the Wayland app_id.
- Clean up the metainfo (also used by the Flatpak): readable description,
  homepage and bug tracker URLs, and an OARS content rating. Validates
  with AppStream 0.15 and 1.0.
The maintained appimagetool defaults to zstd. AppImageLauncher 2.x, the
stable release on many Ubuntu systems, intercepts AppImage launches and
cannot mount zstd images ("Can't open squashfs image: Bad address"), so
the AppImage failed to start there. gzip is supported everywhere.
The maintained appimagetool bundles a mksquashfs that only supports
zstd, so --comp gzip fails the build. Keep zstd: the static type2
runtime it produces needs no libfuse2 and runs on stock Ubuntu.
AppImageLauncher 2.x users can launch with APPIMAGELAUNCHER_DISABLE=1
or use AppImageLauncher 3.
AppImageLauncher 2.x, still the stable release on many Ubuntu systems,
intercepts AppImage launches and its libappimage only opens gzip or xz
squashfs images ("this version supports only xz, zlib"), so the zstd
AppImage failed to start there. The maintained appimagetool's bundled
mksquashfs only supports zstd, so keep it for validation and building,
then repack the squashfs with gzip on the same type2 runtime, which
reads both. Verified in Ubuntu 22.04/24.04 containers, including
AppImageLauncher 2.2.0 integration.

CI installs squashfs-tools and fails if the AppImage is not gzip.
Window (layout inspired by the MousePods desktop app by Matteo Gaudioso,
https://github.com/starman-tech/mousepods; no MousePods code is used):
- Sidebar with app header, device list with live battery, Settings and a
  connection status footer.
- AirPods overview: hero card with battery rings (low/critical colors,
  charging bolt, dimmed bud in case, last known case level), summary
  tiles, segmented noise-control buttons, Audio card and a collapsible
  "About this device".
- Settings as grouped cards; segmented System/Light/Dark colors.
- Reusable components (cards, rows, segmented control, chip, tile,
  battery ring, page header, nav item) in ui/components.rs.
- Use only the bundled SF Pro Regular weight; requesting semibold made
  the text engine substitute another font.

Connect and quit:
- "Not connected" card with a Connect button, e.g. after using the
  AirPods with an iPhone; also in the tray menu, the COSMIC applet and
  `librepods --connect`. Stay on the device page after a disconnect.
- "Quit LibrePods" in the applet popup and `librepods --quit` (the tray
  icon, and its Exit item, is hidden while the applet runs).

Fixes:
- Renames update the sidebar, header and applet, and are saved to
  devices.json.
- Forward ear-detection events to the window.
- Reset the tray/applet/IPC state when the AirPods disconnect; it kept
  showing them as connected with stale battery levels.
- AirPods commands are sent from update() instead of from view callbacks.
- Applet shows the AirPods' name; IPC status includes it.
Reliability:
- Cache devices.json in the window instead of reading it on every redraw.
- Read AirPods state off the UI thread (no blocking_read/blocking_lock in
  update or view); removes two unwraps that could abort the app.
- Use one shared background runtime instead of a runtime per command.
- Send a rename once (on Enter or after typing pauses), not per keystroke.
- Window follows the shared tray/applet status (live case battery from
  BLE broadcasts).
- One settings writer that keeps unknown keys.
- Fix crashes on malformed packets: short ear detection, connected
  devices length check off by 2, short smart routing, malformed address
  in RPA verification.
- Don't truncate the running instance's log when launched again.

Features:
- Low-battery desktop notifications at 20% and 10% (with hysteresis),
  toggle in Settings.
- Pairing helper: pairs AirPods over BR/EDR, avoiding the LE "Find My"
  identity that makes pairing fail on Linux.
- Connect a specific pair when several AirPods are saved (tray, applet,
  `connect <mac>` IPC command).
- Remember the last live case battery across restarts and show its age.

UI:
- "System" theme follows the XDG portal color scheme directly; iced's
  own detection was reset to light when a window opened on Wayland.
- Responsive layout: fixed-width sidebar, icon-only sidebar and stacked
  cards below 720 px; default window size 920x640.
- Sidebar footer shows the version and warns when Bluetooth is off.

Tests: 2 -> 57 (app and applet), including real packet bytes, spec test
vectors for the RPA hash and AES, packet handler, IPC contract, low
battery rules and UI smoke tests. CI also runs the applet's tests.
@satyakommula96

Copy link
Copy Markdown
Author

Hi @kavishdevar ,

could you please review PR

Thanks,
Satya

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.

1 participant