diff --git a/src/bar_modules/bar_module_music.rs b/src/bar_modules/bar_module_music.rs index 135d4d9..1edb04f 100644 --- a/src/bar_modules/bar_module_music.rs +++ b/src/bar_modules/bar_module_music.rs @@ -8,6 +8,7 @@ pub struct UnibarModuleMusic { opts: common::AppOptions, current_stdout :String, progress_stdout :String, + state_stdout: String, } impl UnibarModuleMusic { @@ -17,6 +18,7 @@ impl UnibarModuleMusic { opts: o, current_stdout: "".to_string(), progress_stdout: "".to_string(), + state_stdout: "stopped".to_string(), } } } @@ -47,6 +49,15 @@ impl bar_modules::BarModuleActions for UnibarModuleMusic { self.progress_stdout = String::from_utf8(progress_output.stdout).unwrap(); self.progress_stdout.pop(); } + + let icon_output = Command::new("mpc") + .arg("status") + .arg("%state%") + .stdout(Stdio::piped()) + .output() + .unwrap(); + self.state_stdout = String::from_utf8(icon_output.stdout).unwrap(); + self.state_stdout.pop(); } // -------------------- @@ -63,7 +74,12 @@ impl bar_modules::BarModuleActions for UnibarModuleMusic { // -------------------- fn get_icon(&self) -> String { - return "".to_string(); + // MPD state can be 'playing', 'paused' or 'stopped' + match self.state_stdout.as_str() { + "paused" => return "⏸".to_string(), + "stopped" => return "⏹".to_string(), + _ => return "𝄞".to_string(), + } } } diff --git a/src/main.rs b/src/main.rs index 86833eb..3fee6f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,7 +89,7 @@ impl Unibar { } // Print parts provided by each module - println!("{}", parts.join(" | ")); + println!("{}", parts.join(" ")); } // --------------------