Crates.io | launchctl |
lib.rs | launchctl |
version | 0.2.1 |
source | src |
created_at | 2024-10-29 15:57:42.201847 |
updated_at | 2024-10-29 16:46:42.257495 |
description | A simple library for managing system services on MacOS |
homepage | |
repository | https://github.com/sylvanfranklin/launchctl |
max_upload_size | |
id | 1427156 |
size | 7,055 |
Tiny Rust wrapper library for MacOS service launcher launchctl
. This library
offers a more intuitive interface for managing services on MacOS. Other Rust
crates exist for interfacing with cross platform launch services, I just wanted
one that zeroed in on MacOS. For more info about launchctl
and launchd
see
the official apple docs.
Currently this crate does not support creating or modifying plist files. There are other crates that can give you this behavior, or you can hard code them as strings.
(see docs.rs for more info)
fn main() {
// basic construction of a service
let basic = Service::new("com.<owner>.<binary>", PathBuf::from("/bin/ls"));
// more advanced construction of a service
let custom = Service {
name: "com.<owner>.<binary>".to_string(),
domain_target: "gui/501".to_string(),
service_target: "gui/501/com.<owner>.<binary>".to_string(),
uid: "501".to_string(),
bin_path: "/bin/ls".into(),
plist_path: "/Library/LaunchAgents/com.<owner>.<binary>.plist".to_string(),
error_log_path: "/tmp/<binary>_<user>.err.log".to_string(),
out_log_path: "/tmp/<binary>_<user>.out.log".to_string(),
};
// create a .plist file for the service
// ...
basic.start().unwrap();
}
cargo add launchctl