Skip to content

Commit 8b26952

Browse files
feat: launch app at startup
1 parent 6b32ff0 commit 8b26952

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

src-tauri/Cargo.lock

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ tiny_http = "0.12"
2626
url = "2"
2727
dirs = "5"
2828
tauri-plugin-single-instance = "2.0"
29+
tauri-plugin-autostart = "2.0"
2930

3031
[features]
3132
# by default Tauri runs in production mode

src-tauri/src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,24 @@ fn main() {
3939
let _ = window.unminimize();
4040
}
4141
}))
42+
.plugin(tauri_plugin_autostart::init(
43+
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
44+
Some(vec!["--hidden"]),
45+
))
4246
.manage(AppState {
4347
alert_count: Mutex::new(0),
4448
last_shown: Mutex::new(None),
4549
config: Mutex::new(config),
4650
})
4751
.setup(|app| {
52+
// Enable autostart on first run
53+
use tauri_plugin_autostart::ManagerExt;
54+
let autostart_manager = app.autolaunch();
55+
if !autostart_manager.is_enabled().unwrap_or(false) {
56+
let _ = autostart_manager.enable();
57+
println!("Autostart enabled");
58+
}
59+
4860
let quit = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
4961
let show = MenuItem::with_id(app, "show", "Show Window", true, None::<&str>)?;
5062
let hide = MenuItem::with_id(app, "hide", "Hide Window", true, None::<&str>)?;

0 commit comments

Comments
 (0)