Skip to content

Commit 2a28862

Browse files
committed
stop display when player dies
1 parent 47b7583 commit 2a28862

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "polybar-mpris-watcher-rs"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
edition = "2024"
55
license = "GPL-3.0-or-later"
66
description = "A good music status display for polybar"

src/watcher.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,18 @@ impl Watcher {
6363
update_interval: time::Duration,
6464
max_size: usize,
6565
) -> Result<(), Box<dyn std::error::Error>> {
66-
let playing = Arc::new(RwLock::new(None));
66+
let playing = Arc::new(RwLock::new(None::<PlayingInfo>));
6767
let playing_clone = Arc::clone(&playing);
6868

6969
thread::spawn(move || {
7070
loop {
7171
{
7272
let mut v = playing_clone.write().unwrap();
73-
v.as_mut().map(|info: &mut PlayingInfo| {
74-
println!("{}", info.next());
75-
});
73+
if v.is_some() {
74+
println!("{}", v.as_mut().unwrap().next());
75+
} else {
76+
println!("")
77+
}
7678
}
7779
thread::sleep(update_interval);
7880
}

0 commit comments

Comments
 (0)