Comments (4)
There is no APIs to flash the tray icon.
Alternating between two images should work though, can you provide a minimal repro and information about your OS?
from tray-icon.
#[tauri::command]
pub fn tray_blink(
app: AppHandle,
state: tauri::State<TrayState>,
is_run: bool,
ms: Option<u64>,
icon_path_1: Option<String>,
icon_path_2: Option<String>,
) {
match state.id.lock().as_deref_mut().map(|x| x.as_mut()) {
Ok(Some(v)) => v.abort(),
_ => (),
}
if !is_run {
return;
}
*state.id.lock().unwrap() = Some(tokio::spawn(async move {
let path1 = &icon_path_1.unwrap();
let path2 = &icon_path_2.unwrap();
let mut count = 0;
loop {
tokio::time::sleep(std::time::Duration::from_millis(ms.unwrap_or_else(|| 500))).await;
count += 1;
let path = if count % 2 == 0 {
path2
} else {
path1
};
app
.tray_handle()
.set_icon(tauri::Icon::File(std::path::PathBuf::from(path)))
.unwrap();
}
}));
}
Full tauri info
output
[✔] Environment
- OS: Windows 10.0.26080 X64
✔ WebView2: 122.0.2365.92
✔ MSVC: Visual Studio Community 2022
✔ rustc: 1.77.0 (aedd173a2 2024-03-17)
✔ cargo: 1.77.0 (3fe68eabf 2024-02-29)
✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.10.0
- pnpm: 8.15.4
- yarn: 1.22.21
- npm: 10.2.3
[-] Packages
- tauri [RUST]: 1.6.1
- tauri-build [RUST]: 1.5.0
- wry [RUST]: 0.24.6
- tao [RUST]: 0.16.5
- @tauri-apps/api [NPM]: 1.5.3
- @tauri-apps/cli [NPM]: 1.5.11
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../dist
- devPath: http://localhost:6130/
- framework: Vue.js
- bundler: Rollup
from tray-icon.
QQ2024326-173221-HD.mp4
an icon flashes, similar to wechat
from tray-icon.
I am not sure which icon is yours in the video you showed, but you should be able to simulate what wechat is doing by alternating between a transparent icon and your actual app icon.
I should also note that you're using tauri v1 and this crate is only used in v2.
from tray-icon.
Related Issues (20)
- feat: query the tray icon rect without waiting for an event HOT 1
- Tao example don't show menu on click HOT 2
- MacOS Sonoma displaying more than one icon HOT 10
- How to use MenuItem on Linux? HOT 1
- how to use in tauri v2? HOT 1
- Tray click events on linux not firing HOT 6
- using gtk4? HOT 4
- Handle ctrl+left click as right click on macos HOT 1
- Program crash after closing tray-icon menu without clicking any options HOT 1
- It is not clear how to use it HOT 7
- `mouse-leave` and `mouse-enter` events HOT 1
- macOS: Incorrect tray icon size HOT 2
- `Icon::from_resource` does not support icon without a ordinal id
- Unable to run example directly from terminal, works from IDE (RustRover) HOT 3
- Support template icon on macOS HOT 1
- tray icon menu renders under taskbar HOT 5
- Listening events for tray icons HOT 1
- tray-icon = "0.14.0" Failed to reference on win11 HOT 9
- The enter event is only triggered for the first time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tray-icon.