Fix device detection, tree indentation, and hide Single storage type
- Replace findmnt with lsblk for efficient device name detection - Fix tree indentation to align consistently with status icon text - Hide '(Single)' label for single disk storage pools - Device detection returns actual names (nvme0n1, sda) not UUID paths
This commit is contained in:
parent
9f34c67bfa
commit
ad298ac70c
@ -262,10 +262,10 @@ impl DiskCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Detect device backing a mount point using findmnt (static version for startup)
|
/// Detect device backing a mount point using lsblk (static version for startup)
|
||||||
fn detect_device_for_mount_point_static(mount_point: &str) -> Result<Vec<String>> {
|
fn detect_device_for_mount_point_static(mount_point: &str) -> Result<Vec<String>> {
|
||||||
let output = Command::new("findmnt")
|
let output = Command::new("lsblk")
|
||||||
.args(&["-n", "-o", "SOURCE", mount_point])
|
.args(&["-n", "-o", "NAME,MOUNTPOINT"])
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
@ -273,14 +273,16 @@ impl DiskCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||||
let device_path = output_str.trim();
|
|
||||||
|
|
||||||
// Extract device name from path (e.g., /dev/nvme0n1 -> nvme0n1)
|
for line in output_str.lines() {
|
||||||
if let Some(device_name) = device_path.strip_prefix("/dev/") {
|
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||||
Ok(vec![device_name.to_string()])
|
if parts.len() >= 2 && parts[1] == mount_point {
|
||||||
} else {
|
let device_name = parts[0].trim();
|
||||||
Ok(Vec::new())
|
return Ok(vec![device_name.to_string()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(Vec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get directory size using du command (efficient for single directory)
|
/// Get directory size using du command (efficient for single directory)
|
||||||
|
|||||||
@ -254,9 +254,14 @@ impl SystemWidget {
|
|||||||
_ => "—% —GB/—GB".to_string(),
|
_ => "—% —GB/—GB".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let pool_label = if pool.pool_type.to_lowercase() == "single" {
|
||||||
|
format!("{}:", pool.mount_point)
|
||||||
|
} else {
|
||||||
|
format!("{} ({}):", pool.mount_point, pool.pool_type)
|
||||||
|
};
|
||||||
let pool_spans = StatusIcons::create_status_spans(
|
let pool_spans = StatusIcons::create_status_spans(
|
||||||
pool.status.clone(),
|
pool.status.clone(),
|
||||||
&format!("{} ({}):", pool.mount_point, pool.pool_type)
|
&pool_label
|
||||||
);
|
);
|
||||||
lines.push(Line::from(pool_spans));
|
lines.push(Line::from(pool_spans));
|
||||||
|
|
||||||
@ -280,7 +285,7 @@ impl SystemWidget {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut drive_spans = vec![
|
let mut drive_spans = vec![
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw(tree_symbol),
|
Span::raw(tree_symbol),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
];
|
];
|
||||||
@ -292,7 +297,7 @@ impl SystemWidget {
|
|||||||
if pool.usage_percent.is_some() {
|
if pool.usage_percent.is_some() {
|
||||||
let tree_symbol = "└─";
|
let tree_symbol = "└─";
|
||||||
let mut usage_spans = vec![
|
let mut usage_spans = vec![
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw(tree_symbol),
|
Span::raw(tree_symbol),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
];
|
];
|
||||||
@ -429,7 +434,7 @@ impl Widget for SystemWidget {
|
|||||||
|
|
||||||
let freq_text = self.format_cpu_frequency();
|
let freq_text = self.format_cpu_frequency();
|
||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::raw("└─ "),
|
Span::raw(" └─ "),
|
||||||
Span::styled(format!("Freq: {}", freq_text), Typography::secondary())
|
Span::styled(format!("Freq: {}", freq_text), Typography::secondary())
|
||||||
]));
|
]));
|
||||||
|
|
||||||
@ -443,7 +448,7 @@ impl Widget for SystemWidget {
|
|||||||
|
|
||||||
let tmp_text = self.format_tmp_usage();
|
let tmp_text = self.format_tmp_usage();
|
||||||
let mut tmp_spans = vec![
|
let mut tmp_spans = vec![
|
||||||
Span::raw(" └─ "),
|
Span::raw(" └─ "),
|
||||||
];
|
];
|
||||||
tmp_spans.extend(StatusIcons::create_status_spans(
|
tmp_spans.extend(StatusIcons::create_status_spans(
|
||||||
self.memory_status.clone(),
|
self.memory_status.clone(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user