Skip to content

feat(desktop): MPRIS, system tray, and OS integration (P3-16)#92

Merged
forkwright merged 2 commits intomainfrom
p3-16/system-integration
Mar 14, 2026
Merged

feat(desktop): MPRIS, system tray, and OS integration (P3-16)#92
forkwright merged 2 commits intomainfrom
p3-16/system-integration

Conversation

@forkwright
Copy link
Owner

Summary

  • MPRIS v2 D-Bus service (Linux only, #[cfg(target_os = "linux")]): bridges PlaybackEngine broadcast events to D-Bus PropertiesChanged signals via mpris-server 0.8; supports play/pause/stop/seek/next/previous/volume/shuffle; metadata includes title, artist, album, duration, and track ID
  • System tray: icon with context menu (Play/Pause, Next, Previous, now-playing display, Show/Hide window, Quit); left-click toggles window visibility; right-click shows menu; menu rebuilt on each track change via tray.set_menu()
  • Desktop notifications: track-change notifications gated behind NotificationConfig flags (enabled, show_artist, show_album); additional helpers for download complete, request approved, and library scan events
  • File associations: handle_startup_file checks CLI args at launch for audio paths; handle_file_open emits file-open event consumed by frontend; tauri.conf.json declares fileAssociations for flac/mp3/m4a/m4b/ogg/opus/wav/aac
  • Auto-start: tauri-plugin-autostart wired to autostart_is_enabled / autostart_set IPC commands; persisted in AppConfig
  • Config persistence: AppConfig (window geometry, tray, notifications, autostart, start-minimized) serialised to ~/.config/harmonia/config.json; window state saved on close/resize/move
  • Settings page: General (server URL), System (minimize-to-tray, start-minimized, auto-start), Notifications (enabled + per-field toggles), Audio (link to DSP), About (version/OS/arch)
  • NixOS module: programs.harmonia-desktop option; generates xdg.desktopEntries.harmonia, D-Bus activation via services.dbus.packages, and xdg.mime.defaultApplications for all registered audio types

Test plan

  • cd desktop && npm run lint — no warnings
  • cd desktop && npm run build — clean build
  • cd desktop/src-tauri && cargo check — no errors
  • cd desktop/src-tauri && cargo clippy -- -D warnings — no warnings
  • Launch app; playerctl list shows harmonia
  • playerctl play-pause / playerctl next / playerctl previous control playback
  • playerctl metadata returns current track title, artist, album
  • Media keys on keyboard trigger play/pause/next/previous
  • playerctl volume 0.5 sets volume to 50 %
  • System tray icon visible; left-click hides/shows window
  • Right-click menu shows now-playing line, updates on track change
  • Play/Pause/Next/Previous menu items emit correct events
  • Track-change notification appears when new track starts
  • Notification disabled when notifications.enabled = false
  • Settings page opens; all toggles persist across restart
  • xdg-open some-file.flac opens Harmonia and emits file-open
  • NixOS module syntax: nix-instantiate --parse nix/module.nix

Observations

  • desktop/src-tauri/src/playback/podcast.rs and akroasis/shared/akroasis-core/ have uncommitted changes from a prior session that are outside this PR's scope; left unstaged.
  • TrayIcon<R> in Tauri 2 exposes no menu() getter — the only update path is rebuilding and calling set_menu(); this means every track change rebuilds the full menu (7 items). Acceptable for now; a MenuItem handle cache would allow targeted set_text() updates.
  • mpris-server 0.8 re-exports zbus 4.x as mpris_server::zbus; adding an explicit zbus = "5" dependency creates a type mismatch between zbus::fdo::Error and mpris_server::zbus::fdo::Error. The Cargo.toml must not pin a separate zbus version.
  • Album art URL is not yet included in MPRIS metadata (no mpris:artUrl field set). The TrackInfo struct does not carry a cover URL; plumbing that through is a follow-up.

Implements full OS integration for the Harmonia desktop app:

- MPRIS v2 D-Bus service (Linux only) via mpris-server 0.8; bridges
  PlaybackEngine state changes to PropertiesChanged signals; supports
  play/pause/stop/seek/volume/shuffle/next/previous/metadata
- System tray with icon, playback controls, now-playing display, and
  minimize-to-tray behaviour; left-click toggles window visibility
- Desktop notifications for track changes; configurable per
  NotificationConfig (enabled, show_artist, show_album flags)
- File association handler: emits file-open event for audio files
  passed via CLI or OS "Open With"; handles startup argument
- Auto-start support via tauri-plugin-autostart; persisted in config
- AppConfig struct with window geometry, tray, notification, and
  autostart fields; persisted to JSON via load_config/save_config
- Window state (size, position, maximised) saved on close/resize/move
- Settings page with General, System, Notification, Audio, and About
  sections; all toggles wired to Tauri IPC commands
- tauri.conf.json: fileAssociations for flac/mp3/m4a/m4b/ogg/opus/wav/aac
- NixOS module: programs.harmonia-desktop option with desktop entry,
  D-Bus activation, and xdg.mime.defaultApplications
@github-actions
Copy link
Contributor

⚠️ Large PR detected — 24 files, 2387 lines changed.

Consider splitting into smaller PRs for easier review. Not a blocker, just a signal.

@forkwright forkwright merged commit 2fac949 into main Mar 14, 2026
12 checks passed
@forkwright forkwright deleted the p3-16/system-integration branch March 18, 2026 02:12
This was referenced Mar 18, 2026
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