Added icon to music module
This commit is contained in:
parent
b7f83b4810
commit
b8b0afd945
@ -8,6 +8,7 @@ pub struct UnibarModuleMusic {
|
|||||||
opts: common::AppOptions,
|
opts: common::AppOptions,
|
||||||
current_stdout :String,
|
current_stdout :String,
|
||||||
progress_stdout :String,
|
progress_stdout :String,
|
||||||
|
state_stdout: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnibarModuleMusic {
|
impl UnibarModuleMusic {
|
||||||
@ -17,6 +18,7 @@ impl UnibarModuleMusic {
|
|||||||
opts: o,
|
opts: o,
|
||||||
current_stdout: "".to_string(),
|
current_stdout: "".to_string(),
|
||||||
progress_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 = String::from_utf8(progress_output.stdout).unwrap();
|
||||||
self.progress_stdout.pop();
|
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 {
|
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(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ impl Unibar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print parts provided by each module
|
// Print parts provided by each module
|
||||||
println!("{}", parts.join(" | "));
|
println!("{}", parts.join(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user