diff --git a/src/sound.rs b/src/sound.rs index 7a7ce63..a37382e 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -11,14 +11,15 @@ pub fn get_sound(setting: &Settings) -> String { .output() .unwrap(); - let vol: String = String::from_utf8_lossy(&cmd_content.stdout) - .split('\n') - .collect::>()[4] + let mut vol: String = String::from_utf8_lossy(&cmd_content.stdout) + .lines() + .last() + .expect("failed to get sound volume") .split('[') .collect::>()[1] - .split(']') - .collect::>()[0] + .trim() .to_string(); + vol.remove(vol.len() - 1); format!(" {} {} {}", setting.volume.icon, vol, setting.seperator) }