diff options
Diffstat (limited to 'src/systemd')
-rw-r--r-- | src/systemd/job.rs | 24 | ||||
-rw-r--r-- | src/systemd/mod.rs | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/systemd/job.rs b/src/systemd/job.rs new file mode 100644 index 0000000..68fb18d --- /dev/null +++ b/src/systemd/job.rs @@ -0,0 +1,24 @@ +use std::collections::HashMap; +use std::process::Command; + +use std::io; + +#[derive(Debug)] +pub struct Unit { + name: String, + type_: String +} + +pub fn get_jobs() -> io::Result<Vec<Unit>> { + let mut units = Vec::new(); + let status = try!(Command::new("systemctl") + .args(&["show", "*"]).output()); + + for line in String::from_utf8_lossy(&status.stdout).split('\n') { + let words = line.split('=').collect::<Vec<&str>>(); + if words.len() == 2 && words[0] == "Id" { + units.push(Unit { name: words[1].to_owned(), type_: "Unknown".to_owned() }); + } + } + return Ok(units); +} diff --git a/src/systemd/mod.rs b/src/systemd/mod.rs new file mode 100644 index 0000000..80daa3e --- /dev/null +++ b/src/systemd/mod.rs @@ -0,0 +1 @@ +pub mod job; |