systemd-wake 0.1.0

Use systemd to wake up for future tasks
Documentation

systemd-wake

This is a utility library that uses systemd-run under the hood to schedule any [Command] to run at some future time. Allows for tasks to be scheduled and cancelled using custom systemd unit names as handles. Note that there are no guarantees about naming collisions from other programs. Be smart about choosing names.

Requires the systemd-wake binary to be installed in order to work. Remember to install with cargo install systemd-wake

Use [register()] to schedule a command with systemd-run to wake at specificed time

Use [deregister()] to cancel timer

Example

use systemd_wake::*;

// one minute in the future
let waketime = chrono::Local::now() + chrono::Duration::minutes(1);

// schedule a short beep
let mut command = std::process::Command::new("play");
command.args(vec!["-q","-n","synth","0.1","sin","880"]);

// create unit handle
let timer_name = TimerName::new("my-special-unit-name-123").unwrap();

// register future beep
systemd_wake::register(waketime,timer_name,command).unwrap();

// cancel future beep
systemd_wake::deregister(timer_name).unwrap();