diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index becd9a5..9fa1014 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -210,6 +210,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "auto-launch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f0ab475f9b1049a9d4e9c83f45ff27ec3bce4a6cb8e58e7f29030f8992af8c5" +dependencies = [ + "dirs 4.0.0", + "winreg", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -267,7 +277,9 @@ dependencies = [ name = "brancato" version = "0.9.3" dependencies = [ + "auto-launch", "directories", + "dunce", "execute", "log", "open", @@ -778,6 +790,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + [[package]] name = "dirs-next" version = "2.0.0" @@ -831,6 +852,12 @@ dependencies = [ "dtoa", ] +[[package]] +name = "dunce" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453440c271cf5577fd2a40e4942540cb7d0d2f85e27c8d07dd0023c925a67541" + [[package]] name = "easy-parallel" version = "3.2.0" @@ -1754,7 +1781,7 @@ checksum = "3dfb6b71a9a89cd38b395d994214297447e8e63b1ba5708a9a2b0b1048ceda76" dependencies = [ "cc", "chrono", - "dirs", + "dirs 1.0.5", "objc-foundation", ] @@ -4037,6 +4064,15 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "winres" version = "0.1.12" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 49f808d..d8764a1 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -25,6 +25,8 @@ open = "2.0.2" directories = "4.0.1" log = "0.4" pretty_env_logger = "0.4" +auto-launch = "0.2" +dunce = "1.0.2" [features] # by default Tauri runs in production mode diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 1d78372..0fe3705 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -8,11 +8,13 @@ mod user_config; mod windows; mod workflows; use app_config::{set_custom_user_config_path, AppConfig}; +use auto_launch::{AutoLaunch, AutoLaunchBuilder}; use serde::Serialize; use std::{path::PathBuf, sync::Mutex}; use tauri::{ - api::dialog::blocking::FileDialogBuilder, AppHandle, CustomMenuItem, GlobalShortcutManager, - Manager, RunEvent, State, SystemTray, SystemTrayEvent, SystemTrayMenu, SystemTrayMenuItem, + api::dialog::blocking::FileDialogBuilder, utils::platform::current_exe, AppHandle, + CustomMenuItem, GlobalShortcutManager, Manager, RunEvent, State, SystemTray, SystemTrayEvent, + SystemTrayMenu, SystemTrayMenuItem, }; use user_config::{set_user_config, UserConfig}; @@ -187,8 +189,22 @@ fn open_omnibar(app: &AppHandle) -> Result<(), tauri::Error> { Ok(()) } +pub fn init_autolaunch() -> AutoLaunch { + let app_exe = current_exe().unwrap(); + let app_exe = dunce::canonicalize(app_exe).unwrap(); + let app_name = app_exe.file_stem().unwrap().to_str().unwrap(); + let app_path = app_exe.as_os_str().to_str().unwrap(); + + AutoLaunchBuilder::new() + .set_app_name(app_name) + .set_app_path(app_path) + .build() +} + fn main() { pretty_env_logger::init(); + let autolaunch = init_autolaunch(); + autolaunch.enable().unwrap(); let app_config = app_config::get_or_create_app_config(); let user_config = user_config::get_user_config(app_config.user_config_path.clone());