1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
use std::process::Command;

/// Causes system to hibernate.
///
/// The method uses `systemctl` in order to start hibernation.
pub fn hibernate() {
    Command::new("systemctl")
        .arg("hibernate")
        .spawn()
        .ok();
}