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) (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 ## [0.4.1] - 2020-05-05
### Bug Fixes ### 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) { 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 { let mem_label = "RAM:".to_string()
"".to_string() + &format!(
} else { "{:3.0}%",
"RAM:".to_string() if current_data.memory_harvest.mem_total_in_mb == 0 {
+ &format!( 0.0
"{:3.0}%", } else {
(current_data.memory_harvest.mem_used_in_mb as f64 * 100.0 current_data.memory_harvest.mem_used_in_mb as f64 * 100.0
/ current_data.memory_harvest.mem_total_in_mb as f64) / current_data.memory_harvest.mem_total_in_mb as f64
) }
+ &format!( )
" {:.1}GB/{:.1}GB", + &format!(
current_data.memory_harvest.mem_used_in_mb as f64 / 1024.0, " {:.1}GB/{:.1}GB",
(current_data.memory_harvest.mem_total_in_mb as f64 / 1024.0) 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 { let swap_label = "SWP:".to_string()
"".to_string() + &format!(
} else { "{:3.0}%",
"SWP:".to_string() if current_data.swap_harvest.mem_total_in_mb == 0 {
+ &format!( 0.0
"{:3.0}%", } else {
(current_data.swap_harvest.mem_used_in_mb as f64 * 100.0 current_data.swap_harvest.mem_used_in_mb as f64 * 100.0
/ current_data.swap_harvest.mem_total_in_mb as f64) / current_data.swap_harvest.mem_total_in_mb as f64
) }
+ &format!( )
" {:.1}GB/{:.1}GB", + &format!(
current_data.swap_harvest.mem_used_in_mb as f64 / 1024.0, " {:.1}GB/{:.1}GB",
(current_data.swap_harvest.mem_total_in_mb as f64 / 1024.0) 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) (mem_label, swap_label)
} }