diff --git a/.run/Run Dev Server.run.xml b/.run/Run Dev Server.run.xml
new file mode 100644
index 0000000..5b9b630
--- /dev/null
+++ b/.run/Run Dev Server.run.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.run/Run spary.run.xml b/.run/Run spary.run.xml
new file mode 100644
index 0000000..a9dfb5f
--- /dev/null
+++ b/.run/Run spary.run.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index e94fad3..ac3e447 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -1,8 +1,7 @@
-// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
-
+use tauri::Manager;
use crate::spary::spary_switch;
use tauri::menu::{Menu, MenuItem};
-use tauri::tray::TrayIconBuilder;
+use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
use tauri_plugin_sql::{Migration, MigrationKind};
mod spary;
@@ -52,6 +51,24 @@ pub fn run() {
app.exit(0);
}
})
+ //Linux: Unsupported. The event is not emitted even though the icon is shown and will still show a context menu on right click.
+ .on_tray_icon_event(|tray, event| match event {
+ TrayIconEvent::Click {
+ button: MouseButton::Left,
+ button_state: MouseButtonState::Up,
+ ..
+ } => {
+ let app = tray.app_handle();
+ if let Some(window) = app.get_webview_window("main") {
+ let _ = window.unminimize();
+ let _ = window.show();
+ let _ = window.set_focus();
+ }
+ }
+ _ => {
+ println!("unhandled event {event:?}");
+ }
+ })
.build(app)?;
tray.set_menu(Some(menu))?;
Ok(())