Fix: gracefully handle invalid DBus setups
Some systems may have an ncspot binary with enabled MPRIS/DBus support, even though DBus is not actually running on the system or the session is broken. ncspot should not panic in such a situation, but handle gracefully instead. Should help with #1139
This commit is contained in:
@@ -365,7 +365,7 @@ fn main() -> Result<(), String> {
|
||||
spotify.update_status(state.clone());
|
||||
|
||||
#[cfg(feature = "mpris")]
|
||||
mpris_manager.update()?;
|
||||
mpris_manager.update();
|
||||
|
||||
#[cfg(unix)]
|
||||
ipc.publish(&state, queue.get_current());
|
||||
|
||||
13
src/mpris.rs
13
src/mpris.rs
@@ -484,7 +484,12 @@ impl MprisManager {
|
||||
|
||||
let (tx, rx) = mpsc::unbounded_channel::<()>();
|
||||
|
||||
ASYNC_RUNTIME.spawn(Self::serve(UnboundedReceiverStream::new(rx), root, player));
|
||||
ASYNC_RUNTIME.spawn(async {
|
||||
let result = Self::serve(UnboundedReceiverStream::new(rx), root, player).await;
|
||||
if let Err(e) = result {
|
||||
log::error!("MPRIS error: {e}");
|
||||
}
|
||||
});
|
||||
|
||||
MprisManager { tx }
|
||||
}
|
||||
@@ -518,7 +523,9 @@ impl MprisManager {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&self) -> Result<(), String> {
|
||||
self.tx.send(()).map_err(|e| e.to_string())
|
||||
pub fn update(&self) {
|
||||
if let Err(e) = self.tx.send(()) {
|
||||
log::warn!("Could not update MPRIS state: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user