Skip to content

Instantly share code, notes, and snippets.

@AlexMikhalev
Created June 15, 2021 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexMikhalev/8758f3df25f24e8ea3a74614c200d9a5 to your computer and use it in GitHub Desktop.
Save AlexMikhalev/8758f3df25f24e8ea3a74614c200d9a5 to your computer and use it in GitHub Desktop.
Taury Apps tray icon
fn main() {
let show = CustomMenuItem::new("show".to_string(), "Show");
let hide = CustomMenuItem::new("hide".to_string(), "Hide");
let quit = CustomMenuItem::new("quit".to_string(), "Quit");
let tray_menu_items = vec![
SystemTrayMenuItem::Custom(show),
SystemTrayMenuItem::Custom(hide),
SystemTrayMenuItem::Separator,
SystemTrayMenuItem::Custom(quit),
];
tauri::Builder::default()
.system_tray(tray_menu_items)
.on_system_tray_event(|app, event| match event.menu_item_id().as_str() {
"quit" => {
std::process::exit(0);
}
"show" => {
let window = app.get_window("main").unwrap();
window.show().unwrap();
window.unminimize().unwrap();
}
"hide" => {
let window = app.get_window("main").unwrap();
window.minimize().unwrap();
window.hide().unwrap();
}
_ => {}
})
.invoke_handler(tauri::generate_handler![file_created_at, shellcode, close_app, hard_reset])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment