Merge pull request #8 from MustafaSalih1993/dev

Dev
This commit is contained in:
Mustafa Salih 2020-12-30 03:25:51 +03:00 committed by GitHub
commit 135aa1a210
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -3,7 +3,10 @@ name = "rsblocks"
version = "0.1.0" version = "0.1.0"
authors = ["mustafa salih <mustafasalih1991@gmail.com>"] authors = ["mustafa salih <mustafasalih1991@gmail.com>"]
edition = "2018" edition = "2018"
readme = "README.md"
license = "MIT"
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 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]

View File

@ -6,20 +6,20 @@ use std::process::Command;
pub fn get_sound(setting: &Settings) -> String { pub fn get_sound(setting: &Settings) -> String {
let cmd_content = Command::new("amixer") let cmd_content = Command::new("amixer")
.arg("get") .args(&["-D", "pulse", "get", "Master"])
.arg("Master")
.output() .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() .lines()
.last() .last()
.expect("failed to get sound volume") .expect("failed to get sound volume")
.split('[') .split('[')
.collect::<Vec<&str>>()[1] .collect::<Vec<&str>>()[1]
.split(']')
.collect::<Vec<&str>>()[0]
.trim() .trim()
.to_string(); .to_string();
vol.remove(vol.len() - 1);
format!(" {} {} {}", setting.volume.icon, vol, setting.seperator) format!(" {} {} {}", setting.volume.icon, vol, setting.seperator)
} }