aboutsummaryrefslogtreecommitdiff
path: root/src/disk.rs
blob: 72dd5bfcdf3ae7934896fb86ada75297071406e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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)
}