tray

Crates.iotray
lib.rstray
version0.1.2
created_at2025-11-30 02:37:06.903514+00
updated_at2025-12-02 03:51:27.229073+00
descriptionCross-platform tray icon library, with egui and iced support
homepagehttps://github.com/nobane/tray-rs
repositoryhttps://github.com/nobane/tray-rs
max_upload_size
id1957765
size230,832
(nobane)

documentation

README

tray

Cross-platform system tray icon library for Rust.

Features

  • Native implementations: X11 (Linux), Shell_NotifyIcon (Windows), NSStatusItem (macOS)
  • Full event support: Click, double-click, enter, leave, move
  • Thread-safe: TrayIcon is Send + Sync for use with async runtimes

Installation

cargo add tray

Usage

use tray::{Icon, TrayIconBuilder, TrayIconEvent, MouseButton};

let icon = Icon::from_rgba(rgba_data, 32, 32)?;

let tray = TrayIconBuilder::new()
    .with_icon(icon)
    .with_tooltip("My App")
    .build()?;

// Poll for events
let receiver = TrayIconEvent::receiver();
loop {
    if let Ok(event) = receiver.try_recv() {
        match event {
            TrayIconEvent::Click { button: MouseButton::Right, position, .. } => {
                // Show your own menu/popup at `position`
            }
            _ => {}
        }
    }
    std::thread::sleep(std::time::Duration::from_millis(100));
}

Feature Flags

Feature Description
serde Serialize/deserialize events and IDs

Platform Notes

  • Linux: Uses native X11 system tray protocol.
  • Windows: Uses Shell_NotifyIconW. Handles taskbar restart automatically.
  • macOS: Uses NSStatusItem. Requires main thread (MainThreadMarker).

License

MIT

Commit count: 0

cargo fmt