Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat: run tauri app in background, single-instance, bump rust-version to 1.75

Joe Goldinaa5a755d40d4
diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index 1170baf3a..c411e1ff5 100644
--- a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,13 +1,13 @@
[package]
name = "screenpipe-app"
-version = "0.1.87"
+version = "0.1.89"
description = ""
authors = ["you"]
license = ""
repository = ""
default-run = "screenpipe-app"
edition = "2021"
-rust-version = "1.60"
+rust-version = "1.75"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -86,6 +86,9 @@ screenpipe-audio = { path = "../../../../screenpipe-audio", features = [] }
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-cli = "2.0.0-alpha.2"
+
+[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\"))".dependencies]
+tauri-plugin-single-instance = "2.0.0-rc.1"
# tauri-plugin-updater = "2.0.0-alpha.2"
[features]
diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs
index 33ede914f..63a1ea114 100755
--- a/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -60,7 +60,13 @@ async fn main() {
let sidecar_state = SidecarState(Arc::new(tokio::sync::Mutex::new(None)));
- let app = tauri::Builder::default()
+ let app = tauri::Builder::default().on_window_event(|window, event| match event {
+ tauri::WindowEvent::CloseRequested { api, .. } => {
+ window.hide().unwrap();
+ api.prevent_close();
+ }
+ _ => {}
+ })
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_dialog::init())
@@ -73,6 +79,15 @@ async fn main() {
MacosLauncher::LaunchAgent,
None,
))
+ .plugin(tauri_plugin_single_instance::init(|app, args, cwd| {
+ let windows = app.webview_windows();
+ windows
+ .values()
+ .next()
+ .expect("Sorry, no window found")
+ .set_focus()
+ .expect("Can't focus window!");
+ }))
.manage(sidecar_state)
.invoke_handler(tauri::generate_handler![
spawn_screenpipe,
@@ -166,14 +181,18 @@ async fn main() {
}
_ => (),
});
- main_tray.on_tray_icon_event(move |_tray, event| match event {
+ main_tray.on_tray_icon_event(move |tray, event| match event {
tauri::tray::TrayIconEvent::Click {
button,
button_state,
..
} => {
- if button == MouseButton::Left && button_state == MouseButtonState::Down {
- // Handle left click if needed
+ if button == MouseButton::Left && button_state == MouseButtonState::Up {
+ let app = tray.app_handle();
+ if let Some(window) = app.get_webview_window("main") {
+ let _ = window.show();
+ let _ = window.set_focus();
+ }
}
}
_ => {}