use std::process::Command; use super::Direction; pub fn step(directon: Direction) { //onscroll set(5, directon); } pub fn toggle_mute(saved_volume: u8) { //onclick use super::update_eww_var; let volume = get_current_value(); set(saved_volume, Direction::Absolute); update_eww_var("mute_save", &volume.to_string()); std::process::exit(0); } pub fn get_current_icon() -> Level { //for path var in image (add to defpoll) match get_current_value() { value if value <= 0 => Level::Mute, value if value <= 25 => Level::Low, value if value <= 75 => Level::Mid, _ => Level::High, } } pub fn get_current_value() -> u8 { //for value in circular-progrss (add to defpoll) let value = Command::new("amixer") .arg("sget").arg("Master") .output().unwrap().stdout; let value = String::from_utf8(value).unwrap(); let value: Vec<&str> = value.split("[").collect(); value[3].trim().get(0..value.len()-3).unwrap().parse().unwrap() } fn set(value: u8, directon: Direction) { let mut value = value.to_string(); value.push('%'); match directon { Direction::Up => value.push('+'), Direction::Down => value.push('-'), Direction::Absolute => (), } Command::new("amixer") .arg("sset").arg("Master").arg(value).arg("> /dev/null") .spawn(); } enum Level { High, Mid, Low, Mute, }