Skip to content

Commit

Permalink
Append disk path to disk readout value
Browse files Browse the repository at this point in the history
  • Loading branch information
grtcdr committed Oct 29, 2024
1 parent b300578 commit 85a0f26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ fn handle_readout_disk_space(
} else {
readout_values.push(Readout::new(
ReadoutKey::DiskSpace,
format_disk_space(used, total, opt.disk_space_percentage),
format_disk_space(disk_path, used, total, opt.disk_space_percentage),
))
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/format.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bytesize::ByteSize;
use libmacchina::traits::{BatteryState, PackageManager, ReadoutError};
use std::path::PathBuf;

/// This function should return a new `String` constructed from the value \
/// returned by `traits::GeneralReadout::uptime()`
Expand Down Expand Up @@ -140,12 +141,13 @@ pub fn packages(packages: Vec<(PackageManager, usize)>) -> Result<String, Readou
Ok(string)
}

pub fn disk_space(used: u64, total: u64, percentage: bool) -> String {
pub fn disk_space(path: PathBuf, used: u64, total: u64, percentage: bool) -> String {
let used_kb = ByteSize::b(used);
let total_kb = ByteSize::b(total);
let path = path.display();

let mut output = String::new();
output.push_str(&format!("{used_kb} / {total_kb}"));
output.push_str(&format!("{used_kb} / {total_kb} ({path})"));

if percentage {
let p = (used as f64 / total as f64 * 100f64).ceil() as usize;
Expand Down

0 comments on commit 85a0f26

Please sign in to comment.