{"id":15013137,"url":"https://github.com/tauri-apps/tray-icon","last_synced_at":"2025-05-14T11:09:32.930Z","repository":{"id":64322959,"uuid":"554965557","full_name":"tauri-apps/tray-icon","owner":"tauri-apps","description":"Tray icons for Desktop Applications in Rust.","archived":false,"fork":false,"pushed_at":"2025-04-17T23:11:52.000Z","size":337,"stargazers_count":282,"open_issues_count":20,"forks_count":42,"subscribers_count":12,"default_branch":"dev","last_synced_at":"2025-05-10T22:30:00.051Z","etag":null,"topics":["gui","rust","system-tray","tray","tray-app","tray-application","tray-icon","tray-menu","windowing"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tauri-apps.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-10-20T18:01:15.000Z","updated_at":"2025-05-09T04:38:46.000Z","dependencies_parsed_at":"2023-10-16T11:57:08.356Z","dependency_job_id":"8b7ef0c4-f0c8-4fe7-978b-19af0aa86285","html_url":"https://github.com/tauri-apps/tray-icon","commit_stats":{"total_commits":178,"total_committers":21,"mean_commits":8.476190476190476,"dds":0.6123595505617978,"last_synced_commit":"d9bedf8a7d5802f705d4c42b5bdf8649bc217e9e"},"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Ftray-icon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Ftray-icon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Ftray-icon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Ftray-icon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tauri-apps","download_url":"https://codeload.github.com/tauri-apps/tray-icon/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253631401,"owners_count":21939262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gui","rust","system-tray","tray","tray-app","tray-application","tray-icon","tray-menu","windowing"],"created_at":"2024-09-24T19:43:48.101Z","updated_at":"2025-05-14T11:09:32.835Z","avatar_url":"https://github.com/tauri-apps.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"tray-icon lets you create tray icons for desktop applications.\n\n## Platforms supported:\n\n- Windows\n- macOS\n- Linux (gtk Only)\n\n## Platform-specific notes:\n\n- On Windows and Linux, an event loop must be running on the thread, on Windows, a win32 event loop and on Linux, a gtk event loop. It doesn't need to be the main thread but you have to create the tray icon on the same thread as the event loop.\n- On macOS, an event loop must be running on the main thread so you also need to create the tray icon on the main thread.\n\n### Cargo Features\n\n- `common-controls-v6`: Use `TaskDialogIndirect` API from `ComCtl32.dll` v6 on Windows for showing the predefined `About` menu item dialog.\n- `libxdo`: Enables linking to `libxdo` which is used for the predfined `Copy`, `Cut`, `Paste` and `SelectAll` menu item, see https://github.com/tauri-apps/muda#cargo-features\n- `serde`: Enables de/serializing derives.\n\n## Dependencies (Linux Only)\n\nOn Linux, `gtk`, `libxdo` is used to make the predfined `Copy`, `Cut`, `Paste` and `SelectAll` menu items work and `libappindicator` or `libayatnat-appindicator` are used to create the tray icon, so make sure to install them on your system.\n\n#### Arch Linux / Manjaro:\n\n```sh\npacman -S gtk3 xdotool libappindicator-gtk3 #or libayatana-appindicator\n```\n\n#### Debian / Ubuntu:\n\n```sh\nsudo apt install libgtk-3-dev libxdo-dev libappindicator3-dev #or libayatana-appindicator3-dev\n```\n\n## Examples\n\n#### Create a tray icon without a menu.\n\n```rs\nuse tray_icon::TrayIconBuilder;\n\nlet tray_icon = TrayIconBuilder::new()\n    .with_tooltip(\"system-tray - tray icon library!\")\n    .with_icon(icon)\n    .build()\n    .unwrap();\n```\n\n#### Create a tray icon with a menu.\n\n```rs\nuse tray_icon::{TrayIconBuilder, menu::Menu};\n\nlet tray_menu = Menu::new();\nlet tray_icon = TrayIconBuilder::new()\n    .with_menu(Box::new(tray_menu))\n    .with_tooltip(\"system-tray - tray icon library!\")\n    .with_icon(icon)\n    .build()\n    .unwrap();\n```\n\n## Processing tray events\n\nYou can use `TrayIconEvent::receiver` to get a reference to the `TrayIconEventReceiver`\nwhich you can use to listen to events when a click happens on the tray icon\n\n```rs\nuse tray_icon::TrayIconEvent;\n\nif let Ok(event) = TrayIconEvent::receiver().try_recv() {\n    println!(\"{:?}\", event);\n}\n```\n\nYou can also listen for the menu events using `MenuEvent::receiver` to get events for the tray context menu.\n\n```rs\nuse tray_icon::{TrayIconEvent, menu::{MenuEvent}};\n\nif let Ok(event) = TrayIconEvent::receiver().try_recv() {\n    println!(\"tray event: {:?}\", event);\n}\n\nif let Ok(event) = MenuEvent::receiver().try_recv() {\n    println!(\"menu event: {:?}\", event);\n}\n```\n\n### Note for [winit] or [tao] users:\n\nYou should use [`TrayIconEvent::set_event_handler`] and forward\nthe tray icon events to the event loop by using [`EventLoopProxy`]\nso that the event loop is awakened on each tray icon event.\nSame can be done for menu events using [`MenuEvent::set_event_handler`].\n\n```rust\nenum UserEvent {\n  TrayIconEvent(tray_icon::TrayIconEvent)\n  MenuEvent(tray_icon::menu::MenuEvent)\n}\n\nlet event_loop = EventLoop::\u003cUserEvent\u003e::with_user_event().build().unwrap();\n\nlet proxy = event_loop.create_proxy();\ntray_icon::TrayIconEvent::set_event_handler(Some(move |event| {\n    proxy.send_event(UserEvent::TrayIconEvent(event));\n}));\n\nlet proxy = event_loop.create_proxy();\ntray_icon::menu::MenuEvent::set_event_handler(Some(move |event| {\n    proxy.send_event(UserEvent::MenuEvent(event));\n}));\n```\n\n[`EventLoopProxy`]: https://docs.rs/winit/latest/winit/event_loop/struct.EventLoopProxy.html\n[winit]: https://docs.rs/winit\n[tao]: https://docs.rs/tao\n\n## License\n\nApache-2.0/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftauri-apps%2Ftray-icon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftauri-apps%2Ftray-icon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftauri-apps%2Ftray-icon/lists"}