diff --git a/plugins/autostart/Cargo.toml b/plugins/autostart/Cargo.toml index a899096da4..de000a2739 100644 --- a/plugins/autostart/Cargo.toml +++ b/plugins/autostart/Cargo.toml @@ -24,4 +24,4 @@ serde = { workspace = true } serde_json = { workspace = true } tauri = { workspace = true } thiserror = { workspace = true } -auto-launch = "0.5" +auto-launch = "0.6" diff --git a/plugins/autostart/src/lib.rs b/plugins/autostart/src/lib.rs index 4b4c7c23a9..a07bdc3ad8 100644 --- a/plugins/autostart/src/lib.rs +++ b/plugins/autostart/src/lib.rs @@ -10,6 +10,8 @@ )] #![cfg(not(any(target_os = "android", target_os = "ios")))] +#[cfg(target_os = "macos")] +use auto_launch::MacOSLaunchMode; use auto_launch::{AutoLaunch, AutoLaunchBuilder}; use serde::{ser::Serializer, Serialize}; use tauri::{ @@ -190,10 +192,10 @@ impl Builder { #[cfg(target_os = "macos")] { - builder.set_use_launch_agent(matches!( - self.macos_launcher, - MacosLauncher::LaunchAgent - )); + builder.set_macos_launch_mode(match self.macos_launcher { + MacosLauncher::LaunchAgent => MacOSLaunchMode::LaunchAgent, + MacosLauncher::AppleScript => MacOSLaunchMode::AppleScript, + }); // on macOS, current_exe gives path to /Applications/Example.app/MacOS/Example // but this results in seeing a Unix Executable in macOS login items // It must be: /Applications/Example.app @@ -222,6 +224,11 @@ impl Builder { builder.set_app_path(¤t_exe.display().to_string()); } + // FreeBSD has no AppImage concept and tauri's `Env` has no + // `appimage` field under FreeBSD, so just use the current exe path. + #[cfg(target_os = "freebsd")] + builder.set_app_path(¤t_exe.display().to_string()); + app.manage(AutoLaunchManager( builder.build().map_err(|e| e.to_string())?, ));