summaryrefslogtreecommitdiff
path: root/src/systemd/job.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemd/job.rs')
-rw-r--r--src/systemd/job.rs24
1 files changed, 24 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);
+}