From dc451435ed739a0c955369980ad571ca077439ae Mon Sep 17 00:00:00 2001 From: mustafa salih Date: Wed, 30 Dec 2020 03:22:00 +0300 Subject: [PATCH] a little optim --- Cargo.toml | 1 - src/sound.rs | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index efdb3e8..3c57302 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ authors = ["mustafa salih "] edition = "2018" readme = "README.md" license = "MIT" -license-file = "LICENSE" repository = "https://github.com/MustafaSalih1993/rsblocks" description = "This is a minimal status bar for dwm window manager for linux" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/sound.rs b/src/sound.rs index a37382e..6367cac 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -6,20 +6,20 @@ use std::process::Command; pub fn get_sound(setting: &Settings) -> String { let cmd_content = Command::new("amixer") - .arg("get") - .arg("Master") + .args(&["-D", "pulse", "get", "Master"]) .output() - .unwrap(); + .expect("Make sure that you have alsa-utils installed on your system"); - let mut vol: String = String::from_utf8_lossy(&cmd_content.stdout) + let 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) }