auto start stuff?

This commit is contained in:
CJ Pais 2025-05-15 15:14:27 -07:00
parent 3414a6aee8
commit 1e976d62b1
2 changed files with 32 additions and 9 deletions

View file

@ -1,6 +1,17 @@
{
"identifier": "desktop-capability",
"platforms": ["macOS", "windows", "linux"],
"windows": ["main"],
"permissions": ["autostart:default", "global-shortcut:default"]
}
"platforms": [
"macOS",
"windows",
"linux"
],
"windows": [
"main"
],
"permissions": [
"autostart:default",
"global-shortcut:default",
"autostart:default",
"autostart:default"
]
}

View file

@ -12,7 +12,7 @@ use tauri::image::Image;
use tauri::menu::{Menu, MenuItem};
use tauri::tray::TrayIconBuilder;
use tauri::Manager;
use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_autostart::{MacosLauncher, ManagerExt};
#[derive(Default)]
struct ShortcutToggleStates {
@ -29,14 +29,14 @@ pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_autostart::init(
MacosLauncher::LaunchAgent,
Some(vec!["--auto-launch"]),
))
.plugin(tauri_plugin_macos_permissions::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
.plugin(tauri_plugin_autostart::init(
MacosLauncher::LaunchAgent,
Some(vec![]),
))
.manage(Mutex::new(ShortcutToggleStates::default()))
.setup(move |app| {
let settings_i = MenuItem::with_id(app, "settings", "Settings", true, None::<&str>)?;
@ -81,6 +81,18 @@ pub fn run() {
.build(app)?;
app.manage(tray);
// Get the autostart manager
let autostart_manager = app.autolaunch();
// Enable autostart
let _ = autostart_manager.enable();
// Check enable state
println!(
"registered for autostart? {}",
autostart_manager.is_enabled().unwrap()
);
// Disable autostart
let _ = autostart_manager.disable();
let recording_manager = Arc::new(
AudioRecordingManager::new(app).expect("Failed to initialize recording manager"),
);