| Crates.io | auto-launcher |
| lib.rs | auto-launcher |
| version | 0.6.1 |
| created_at | 2025-10-20 02:03:33.775839+00 |
| updated_at | 2025-10-20 02:10:40.578971+00 |
| description | Auto launch any application or executable at startup. Supports Windows, macOS, and Linux. |
| homepage | |
| repository | https://github.com/gaojunran/auto-launch.git |
| max_upload_size | |
| id | 1891286 |
| size | 64,158 |
[!NOTE] This crate was forked from zzzgydi/auto-launch, adding more platforms support and features.
Auto launch any application or executable at startup. Supports Windows, macOS, and Linux.
If you find any bugs, welcome to PR or issue.
The parameters of AutoLaunch::new are different on each platform.
See the function definition or the demo below for details.
AutoLaunchBuilder helps to eliminate the constructor difference on various platforms.
use auto_launcher::*;
fn main() {
let auto = AutoLaunchBuilder::new()
.set_app_name("the-app")
.set_app_path("/path/to/the-app")
.set_macos_launch_mode(MacOSLaunchMode::LaunchAgent)
.build()
.unwrap();
auto.enable().unwrap();
auto.is_enabled().unwrap();
auto.disable().unwrap();
auto.is_enabled().unwrap();
}
Linux supports two ways to achieve auto launch:
.desktop files in ~/.config/autostart/ (default)~/.config/systemd/user/use auto_launcher::{AutoLaunch, LinuxLaunchMode};
fn main() {
let app_name = "the-app";
let app_path = "/path/to/the-app";
// Use XDG Autostart (default method)
let auto = AutoLaunch::new(app_name, app_path, LinuxLaunchMode::XdgAutostart, &[] as &[&str]);
// Or use systemd user service
// let auto = AutoLaunch::new(app_name, app_path, LinuxLaunchMode::Systemd, &[] as &[&str]);
// enable the auto launch
auto.enable().is_ok();
auto.is_enabled().unwrap();
// disable the auto launch
auto.disable().is_ok();
auto.is_enabled().unwrap();
}
macOS supports two ways to achieve auto launch:
~/Library/LaunchAgents/ (default)Note:
app_path should be a absolute path and exists. Otherwise, it will cause an error when enable.app_name should be same as the basename of app_path, or it will be corrected automatically.--hidden and --minimized in args are valid, which means that hide the app on launch.use auto_launcher::{AutoLaunch, MacOSLaunchMode};
fn main() {
let app_name = "the-app";
let app_path = "/path/to/the-app.app";
// Use Launch Agent (default method)
let auto = AutoLaunch::new(app_name, app_path, MacOSLaunchMode::LaunchAgent, &[] as &[&str], &[] as &[&str], "");
// Or use AppleScript
// let auto = AutoLaunch::new(app_name, app_path, MacOSLaunchMode::AppleScript, &[] as &[&str], &[] as &[&str], "");
// enable the auto launch
auto.enable().is_ok();
auto.is_enabled().unwrap();
// disable the auto launch
auto.disable().is_ok();
auto.is_enabled().unwrap();
}
On Windows, it will add registry entries under \HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run and \HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run.
It will also detect if startup is disabled inside Task Manager or the Windows settings UI, and can re-enable after being disabled in one of those.
use auto_launcher::AutoLaunch;
fn main() {
let app_name = "the-app";
let app_path = "C:\\path\\to\\the-app.exe";
let auto = AutoLaunch::new(app_name, app_path, &[] as &[&str]);
// enable the auto launch
auto.enable().is_ok();
auto.is_enabled().unwrap();
// disable the auto launch
auto.disable().is_ok();
auto.is_enabled().unwrap();
}
MIT License. See the License file for details.