Skip to content

Use an app-specific Linux tray id to avoid tray-icon collisions with other Tauri apps #1977

@lidaxian121

Description

@lidaxian121

On Linux, cc-switch currently builds its tray icon with TrayIconBuilder::with_id("main").

That becomes a problem when another Tauri app does the same thing. The tray-icon crate uses the tray id to derive both the AppIndicator identifier and the temporary PNG path under $XDG_RUNTIME_DIR/tray-icon, so two apps using the same id end up sharing the same runtime resources.

Concrete example:

  • cc-switch uses with_id("main")
  • clash-verge-rev also uses with_id("main")
  • cc-switch starts first and exposes /run/user/$UID/tray-icon/tray-icon-main-0.png
  • Starting clash-verge-rev creates the same tray-icon-main-0.png, then updates its icon to tray-icon-main-1.png / tray-icon-main-3.png
  • During that update, tray-icon deletes the previously active tray-icon-main-0.png
  • GNOME AppIndicator then tries to refresh cc-switch using the stale path and the icon disappears or falls back to an error/placeholder icon

This is not specific to Clash Verge Rev; that app is just an easy reproducer because it also uses Tauri + tray-icon and also uses "main" as the tray id.

Suggested fix:

  • use an app-specific tray id such as "cc-switch"
  • update internal tray_by_id("main") call sites to use the same app-specific tray id constant

I have a small PR ready that does exactly that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions