aboutsummaryrefslogtreecommitdiff
path: root/src/disk.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/disk.rs')
-rw-r--r--src/disk.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/disk.rs b/src/disk.rs
new file mode 100644
index 0000000..72dd5bf
--- /dev/null
+++ b/src/disk.rs
@@ -0,0 +1,19 @@
+use std::process::Command;
+
+pub fn disk_free() -> String {
+ let cmd = Command::new("sh")
+ .arg("-c")
+ .args(&["df -h"])
+ .output()
+ .unwrap();
+ let output = String::from_utf8_lossy(&cmd.stdout);
+ let mut disk_used = String::new();
+ for line in output.lines() {
+ if line.ends_with('/') {
+ let splited = line.split_whitespace().collect::<Vec<&str>>();
+ disk_used = splited[2].to_string();
+ break;
+ }
+ }
+ format!("  {} │", disk_used)
+}