diff options
author | mustafa salih <mustafasalih1991@gmail.com> | 2020-12-24 04:34:32 +0300 |
---|---|---|
committer | mustafa salih <mustafasalih1991@gmail.com> | 2020-12-24 04:34:32 +0300 |
commit | ffad8074c4b4a1e7a7af281126637499d1242ee7 (patch) | |
tree | aecb1ca581bd64e279c8fb43dd894db1628bf5a2 /src/sound.rs | |
parent | d34ef0dd0392674d1a7a8f098b9c57945e96683a (diff) |
Added sound/volume and it can be customized through the rsblocks.yml file
Diffstat (limited to 'src/sound.rs')
-rw-r--r-- | src/sound.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sound.rs b/src/sound.rs new file mode 100644 index 0000000..7a7ce63 --- /dev/null +++ b/src/sound.rs @@ -0,0 +1,24 @@ +use crate::load_config::Settings; +use std::process::Command; + +// TODO: what a horrible solution to get the sound, i dont like it +// find another way you dumb fuck + +pub fn get_sound(setting: &Settings) -> String { + let cmd_content = Command::new("amixer") + .arg("get") + .arg("Master") + .output() + .unwrap(); + + let vol: String = String::from_utf8_lossy(&cmd_content.stdout) + .split('\n') + .collect::<Vec<&str>>()[4] + .split('[') + .collect::<Vec<&str>>()[1] + .split(']') + .collect::<Vec<&str>>()[0] + .to_string(); + + format!(" {} {} {}", setting.volume.icon, vol, setting.seperator) +} |