From af8404032198a55ed03ff9b507deae1fb4773543 Mon Sep 17 00:00:00 2001 From: Daniel Knuettel Date: Tue, 16 Apr 2024 20:58:30 +0200 Subject: [PATCH] some fixes --- src/make_prompt.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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) } }