Skip to content

Commit

Permalink
fix tray on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredolx committed Jan 14, 2025
1 parent ddf4a0c commit 7640a01
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,22 @@ pub fn run() {
..Default::default()
}));
let quit_i = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&quit_i])?;
let show_i = MenuItem::with_id(app, "show", "Show", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&show_i, &quit_i])?;
TrayIconBuilder::new()
.menu(&menu)
.show_menu_on_left_click(false)
.on_menu_event(|app, event| match event.id.as_ref() {
"quit" => {
app.exit(0);
}
},
"show" => {
if let Some(window) = app.get_webview_window("main") {
let _ = window.unminimize();
let _ = window.show();
let _ = window.set_focus();
}
},
_ => {}
})
.on_tray_icon_event(|tray, event| match event {
Expand Down

0 comments on commit 7640a01

Please sign in to comment.