workaround for ampersand
This commit is contained in:
parent
bf14725f30
commit
08f8a0a134
@ -1,26 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Ferit Yiğit BALABAN, <fybalaban@fybx.dev>
|
||||||
|
* nowplaying.rs 2023
|
||||||
|
*/
|
||||||
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let output0 = Command::new("/usr/bin/playerctl")
|
let output0 = Command::new("playerctl")
|
||||||
.arg("status")
|
.arg("status")
|
||||||
.output()
|
.output()
|
||||||
.expect("err: call playerctl status");
|
.expect("err: call playerctl status");
|
||||||
|
|
||||||
|
|
||||||
let status = String::from_utf8_lossy(&output0.stdout);
|
let status = String::from_utf8_lossy(&output0.stdout);
|
||||||
|
|
||||||
if status == "Playing\n" {
|
match status.trim() {
|
||||||
let output1 = Command::new("/usr/bin/playerctl")
|
"Playing" => {
|
||||||
|
let output1 = Command::new("playerctl")
|
||||||
.arg("-f")
|
.arg("-f")
|
||||||
.arg("'{{trunc(xesam:artist, 15)}} - {{trunc(xesam:title, 30)}}'")
|
.arg("{{trunc(xesam:artist, 15)}} - {{trunc(xesam:title, 30)}}")
|
||||||
.arg("metadata")
|
.arg("metadata")
|
||||||
.output()
|
.output()
|
||||||
.expect("err: call playerctl metadata");
|
.expect("err: call playerctl metadata");
|
||||||
let music = &String::from_utf8(output1.stdout).unwrap();
|
let music = String::from_utf8(output1.stdout).unwrap();
|
||||||
println!("{}", &music[1..music.len() - 2]);
|
let music = music.replace("&", "&");
|
||||||
} else if status == "Paused\n" {
|
println!("{}", music);
|
||||||
println!("Paused\n");
|
}
|
||||||
} else {
|
"Paused" => {
|
||||||
println!("");
|
println!("Paused");
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
println!("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user