feat: add option to launch app at Windows startup
record-daemon / Build, check and test (push) Successful in 2m23s
record-daemon / Build, check and test (push) Successful in 2m23s
- Add tauri-plugin-autostart dependency to Cargo.toml - Add autostart permissions to capabilities/default.json - Initialize autostart plugin in lib.rs with LaunchAgent config - Add "Launch at Startup" toggle in Settings.vue Daemon tab with state management and async enable/disable functions
This commit is contained in:
Generated
+74
-8
@@ -216,6 +216,17 @@ version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "auto-launch"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f012b8cc0c850f34117ec8252a44418f2e34a2cf501de89e29b241ae5f79471"
|
||||
dependencies = [
|
||||
"dirs 4.0.0",
|
||||
"thiserror 1.0.69",
|
||||
"winreg 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
@@ -740,7 +751,16 @@ version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
"dirs-sys 0.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
||||
dependencies = [
|
||||
"dirs-sys 0.3.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -749,7 +769,18 @@ version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
"dirs-sys 0.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users 0.4.6",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -760,7 +791,7 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"redox_users 0.5.2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
@@ -872,7 +903,7 @@ dependencies = [
|
||||
"rustc_version",
|
||||
"toml 0.9.12+spec-1.1.0",
|
||||
"vswhom",
|
||||
"winreg",
|
||||
"winreg 0.55.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1971,6 +2002,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-autostart",
|
||||
"tauri-plugin-opener",
|
||||
"tokio",
|
||||
"uuid",
|
||||
@@ -2990,6 +3022,17 @@ dependencies = [
|
||||
"bitflags 2.11.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
||||
dependencies = [
|
||||
"getrandom 0.2.17",
|
||||
"libredox",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.5.2"
|
||||
@@ -3770,7 +3813,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"cookie",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
"embed_plist",
|
||||
"getrandom 0.3.4",
|
||||
@@ -3821,7 +3864,7 @@ checksum = "4bbc990d1dbf57a8e1c7fa2327f2a614d8b757805603c1b9ba5c81bade09fd4d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_toml",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"glob",
|
||||
"heck 0.5.0",
|
||||
"json-patch",
|
||||
@@ -3893,6 +3936,20 @@ dependencies = [
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-autostart"
|
||||
version = "2.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "459383cebc193cdd03d1ba4acc40f2c408a7abce419d64bdcd2d745bc2886f70"
|
||||
dependencies = [
|
||||
"auto-launch",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-opener"
|
||||
version = "2.5.3"
|
||||
@@ -4345,7 +4402,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5e85aa143ceb072062fc4d6356c1b520a51d636e7bc8e77ec94be3608e5e80c"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"libappindicator",
|
||||
"muda",
|
||||
"objc2",
|
||||
@@ -5297,6 +5354,15 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.55.0"
|
||||
@@ -5411,7 +5477,7 @@ dependencies = [
|
||||
"block2",
|
||||
"cookie",
|
||||
"crossbeam-channel",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"dom_query",
|
||||
"dpi",
|
||||
"dunce",
|
||||
|
||||
@@ -20,6 +20,7 @@ tauri-build = { version = "2", features = [] }
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = ["protocol-asset"] }
|
||||
tauri-plugin-opener = "2"
|
||||
tauri-plugin-autostart = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
|
||||
@@ -395,6 +395,10 @@ fn get_video_metadata(video_path: String) -> Result<Value, String> {
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
|
||||
Some(vec!["--hidden"]),
|
||||
))
|
||||
.setup(|app| {
|
||||
// Auto-start the record-daemon on app launch.
|
||||
// We spawn a background task so the UI isn't blocked while the
|
||||
|
||||
@@ -37,6 +37,8 @@ const daemonStatus = ref<DaemonStatusResponse | null>(null);
|
||||
const encoders = ref<EncodersResponse | null>(null);
|
||||
const daemonRunning = ref(false);
|
||||
const statusPolling = ref<ReturnType<typeof setInterval> | null>(null);
|
||||
const autostartEnabled = ref(false);
|
||||
const autostartLoading = ref(false);
|
||||
|
||||
// Active settings tab
|
||||
type SettingsTab = "video" | "output" | "audio" | "daemon";
|
||||
@@ -97,6 +99,35 @@ async function refreshStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Autostart management
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function checkAutostart() {
|
||||
try {
|
||||
autostartEnabled.value = await invoke<boolean>("plugin:autostart|is_enabled");
|
||||
} catch {
|
||||
autostartEnabled.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleAutostart() {
|
||||
autostartLoading.value = true;
|
||||
try {
|
||||
if (autostartEnabled.value) {
|
||||
await invoke("plugin:autostart|disable");
|
||||
autostartEnabled.value = false;
|
||||
} else {
|
||||
await invoke("plugin:autostart|enable");
|
||||
autostartEnabled.value = true;
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = `Failed to ${autostartEnabled.value ? 'disable' : 'enable'} autostart: ${e}`;
|
||||
} finally {
|
||||
autostartLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Save settings
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -240,6 +271,7 @@ const statusColor = computed(() => {
|
||||
|
||||
onMounted(async () => {
|
||||
await loadSettings();
|
||||
await checkAutostart();
|
||||
// Poll daemon status every 3 seconds
|
||||
statusPolling.value = setInterval(refreshStatus, 3000);
|
||||
});
|
||||
@@ -651,6 +683,23 @@ onUnmounted(() => {
|
||||
|
||||
<!-- Daemon tab -->
|
||||
<div v-if="activeTab === 'daemon'" class="tab-content">
|
||||
<section class="settings-section">
|
||||
<h3>Startup</h3>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Launch at Startup</label>
|
||||
<label class="toggle">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="autostartEnabled"
|
||||
:disabled="autostartLoading"
|
||||
@change="toggleAutostart"
|
||||
/>
|
||||
<span class="toggle-slider"></span>
|
||||
</label>
|
||||
<span class="form-hint">Automatically launch League Recorder when you log in to Windows</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="settings-section">
|
||||
<h3>Daemon Behavior</h3>
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user