force SWAP and RAM labels to show even if at 0

This commit is contained in:
ClementTsang 2020-05-11 22:48:37 -04:00
parent 137e3cea5f
commit ce563542ee
2 changed files with 32 additions and 30 deletions

View file

@ -35,6 +35,8 @@ is equivalent to:
(btm AND cpu > 0) AND (discord AND mem > 0)
```
- [#151](https://github.com/ClementTsang/bottom/issues/151) - Fixed an issue where if the drive I/O label didn't match any disk, the entire disk widget would display nothing.
## [0.4.1] - 2020-05-05
### Bug Fixes

View file

@ -225,37 +225,37 @@ pub fn convert_swap_data_points(
}
pub fn convert_mem_labels(current_data: &data_farmer::DataCollection) -> (String, String) {
let mem_label = if current_data.memory_harvest.mem_total_in_mb == 0 {
"".to_string()
} else {
"RAM:".to_string()
+ &format!(
"{:3.0}%",
(current_data.memory_harvest.mem_used_in_mb as f64 * 100.0
/ current_data.memory_harvest.mem_total_in_mb as f64)
)
+ &format!(
" {:.1}GB/{:.1}GB",
current_data.memory_harvest.mem_used_in_mb as f64 / 1024.0,
(current_data.memory_harvest.mem_total_in_mb as f64 / 1024.0)
)
};
let mem_label = "RAM:".to_string()
+ &format!(
"{:3.0}%",
if current_data.memory_harvest.mem_total_in_mb == 0 {
0.0
} else {
current_data.memory_harvest.mem_used_in_mb as f64 * 100.0
/ current_data.memory_harvest.mem_total_in_mb as f64
}
)
+ &format!(
" {:.1}GB/{:.1}GB",
current_data.memory_harvest.mem_used_in_mb as f64 / 1024.0,
(current_data.memory_harvest.mem_total_in_mb as f64 / 1024.0)
);
let swap_label = if current_data.swap_harvest.mem_total_in_mb == 0 {
"".to_string()
} else {
"SWP:".to_string()
+ &format!(
"{:3.0}%",
(current_data.swap_harvest.mem_used_in_mb as f64 * 100.0
/ current_data.swap_harvest.mem_total_in_mb as f64)
)
+ &format!(
" {:.1}GB/{:.1}GB",
current_data.swap_harvest.mem_used_in_mb as f64 / 1024.0,
(current_data.swap_harvest.mem_total_in_mb as f64 / 1024.0)
)
};
let swap_label = "SWP:".to_string()
+ &format!(
"{:3.0}%",
if current_data.swap_harvest.mem_total_in_mb == 0 {
0.0
} else {
current_data.swap_harvest.mem_used_in_mb as f64 * 100.0
/ current_data.swap_harvest.mem_total_in_mb as f64
}
)
+ &format!(
" {:.1}GB/{:.1}GB",
current_data.swap_harvest.mem_used_in_mb as f64 / 1024.0,
(current_data.swap_harvest.mem_total_in_mb as f64 / 1024.0)
);
(mem_label, swap_label)
}