diff --git a/src/application.rs b/src/application.rs index f64130f4..fb76d901 100644 --- a/src/application.rs +++ b/src/application.rs @@ -22,7 +22,7 @@ use crate::{authentication, ui, utils}; use crate::{command, queue, spotify}; #[cfg(feature = "mpris")] -use crate::mpris::{self, MprisManager}; +use crate::mpris::MprisManager; #[cfg(unix)] use crate::ipc::{self, IpcSocket}; @@ -68,9 +68,6 @@ pub struct Application { /// Internally shared event_manager: EventManager, /// An IPC implementation using the D-Bus MPRIS protocol, used to control and inspect ncspot. - #[cfg(feature = "mpris")] - mpris_manager: MprisManager, - /// An IPC implementation using a Unix domain socket, used to control and inspect ncspot. #[cfg(unix)] ipc: Option, /// The object to render to the terminal. @@ -130,7 +127,7 @@ impl Application { )); #[cfg(feature = "mpris")] - let mpris_manager = mpris::MprisManager::new( + let mpris_manager = MprisManager::new( event_manager.clone(), queue.clone(), library.clone(), @@ -229,8 +226,6 @@ impl Application { queue, spotify, event_manager, - #[cfg(feature = "mpris")] - mpris_manager, #[cfg(unix)] ipc, cursive, diff --git a/src/mpris.rs b/src/mpris.rs index 0a998a31..44cbaf5c 100644 --- a/src/mpris.rs +++ b/src/mpris.rs @@ -465,11 +465,12 @@ impl MprisPlayer { /// Commands to control the [MprisManager] worker thread. #[derive(Debug)] pub enum MprisCommand { - /// Notify about playback status and metadata updates. - PlaybackUpdate, - /// Notify about volume updates. - VolumeUpdate, - MetadataUpdate, + /// Emit playback status + Playback, + /// Emit volume + Volume, + /// Emit metadata + Metadata, } /// An MPRIS server that internally manager a thread which can be sent commands. This is internally @@ -527,14 +528,14 @@ impl MprisManager { loop { let ctx = player_iface_ref.signal_context(); match rx.next().await { - Some(MprisCommand::PlaybackUpdate) => { + Some(MprisCommand::Playback) => { player_iface.playback_status_changed(ctx).await?; } - Some(MprisCommand::VolumeUpdate) => { + Some(MprisCommand::Volume) => { info!("sending MPRIS volume update signal"); player_iface.volume_changed(ctx).await?; } - Some(MprisCommand::MetadataUpdate) => { + Some(MprisCommand::Metadata) => { player_iface.metadata_changed(ctx).await?; } None => break, diff --git a/src/queue.rs b/src/queue.rs index 69f6ba17..ced8ad4b 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -8,7 +8,7 @@ use notify_rust::Notification; use rand::prelude::*; use strum_macros::Display; -use crate::config::{Config}; +use crate::config::Config; use crate::library::Library; use crate::model::playable::Playable; use crate::spotify::PlayerEvent; diff --git a/src/spotify.rs b/src/spotify.rs index 3feaa578..aeaf1770 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -317,7 +317,7 @@ impl Spotify { )); #[cfg(feature = "mpris")] - self.send_mpris(MprisCommand::MetadataUpdate); + self.send_mpris(MprisCommand::Metadata); } /// Update the cached status of the [Player]. This makes sure the status @@ -342,8 +342,8 @@ impl Spotify { let mut status = self.status.write().unwrap(); *status = new_status; - #[cfg(feature ="mpris")] - self.send_mpris(MprisCommand::PlaybackUpdate); + #[cfg(feature = "mpris")] + self.send_mpris(MprisCommand::Playback); } /// Reset the time tracking stats for the current song. This should be called when a new song is @@ -369,7 +369,7 @@ impl Spotify { } /// Send an [MprisCommand] to the mpris thread. - #[cfg(feature ="mpris")] + #[cfg(feature = "mpris")] fn send_mpris(&self, cmd: MprisCommand) { debug!("Sending mpris command: {:?}", cmd); if let Some(mpris_manager) = self.mpris.lock().unwrap().as_ref() { @@ -435,7 +435,7 @@ impl Spotify { // MPRIS implementation. if notify { #[cfg(feature = "mpris")] - self.send_mpris(MprisCommand::VolumeUpdate) + self.send_mpris(MprisCommand::Volume) } }