diff --git a/src/make_prompt.rs b/src/make_prompt.rs index cf0ad3c..6e3978a 100644 --- a/src/make_prompt.rs +++ b/src/make_prompt.rs @@ -52,6 +52,11 @@ fn battery_info(width_to: usize) -> String let mut percentage = String::new(); let _ = file.read_to_string(&mut percentage); + + if percentage.ends_with('\n') + { + percentage.pop(); + } let status_path = bat_path.join("status"); let mut file = match File::open(&status_path) { @@ -63,11 +68,11 @@ fn battery_info(width_to: usize) -> String if status.contains("Charging") || status.contains("Full") { - fixed_width(&format!("{SYMB_POWER} {percentage}%"), width_to + 1) + fixed_width(&format!("{SYMB_POWER} {percentage}%"), width_to) } else { - fixed_width(&format!("{SYMB_BATT} {percentage}%"), width_to) + fixed_width(&format!("{SYMB_BATT} {percentage}%"), width_to - 1) } }