Skip to content

Commit

Permalink
feat: Configure autostart
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev committed Dec 24, 2024
1 parent c529c15 commit 4c27b68
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 5 deletions.
65 changes: 60 additions & 5 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ tauri-plugin-fs = "2"
tauri-plugin-shell = "2"

[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-autostart = "2"
tauri-plugin-single-instance = "2"

11 changes: 11 additions & 0 deletions src-tauri/capabilities/desktop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"identifier": "desktop-capability",
"platforms": [
"macOS",
"windows",
"linux"
],
"permissions": [
"autostart:default"
]
}
19 changes: 19 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ use tauri::Manager;
fn main() {
let mut builder = tauri::Builder::default();

builder = builder.setup(|app| {
#[cfg(desktop)]
{
use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_autostart::ManagerExt;

let _ = app.handle().plugin(tauri_plugin_autostart::init(
MacosLauncher::LaunchAgent,
Some(vec![]),
));

// Get the autostart manager
let autostart_manager = app.autolaunch();
// Enable autostart
let _ = autostart_manager.enable();
}
Ok(())
});

#[cfg(desktop)]
{
builder = builder.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
Expand Down

0 comments on commit 4c27b68

Please # to comment.