use cfg of spotify object
TODO: - apply this to other single config values that are passed directly, e.g. in the statusbar - use a more appropriate object to hold `cfg`
This commit is contained in:
@@ -19,7 +19,7 @@ pub struct Config {
|
|||||||
pub backend_device: Option<String>,
|
pub backend_device: Option<String>,
|
||||||
pub volnorm: Option<bool>,
|
pub volnorm: Option<bool>,
|
||||||
pub volnorm_pregain: Option<f32>,
|
pub volnorm_pregain: Option<f32>,
|
||||||
pub notify: Option<bool>
|
pub notify: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
||||||
|
|||||||
@@ -224,10 +224,7 @@ fn main() {
|
|||||||
&cfg,
|
&cfg,
|
||||||
));
|
));
|
||||||
|
|
||||||
let queue = Arc::new(queue::Queue::new(
|
let queue = Arc::new(queue::Queue::new(spotify.clone()));
|
||||||
spotify.clone(),
|
|
||||||
cfg.notify.unwrap_or(false),
|
|
||||||
));
|
|
||||||
|
|
||||||
#[cfg(feature = "mpris")]
|
#[cfg(feature = "mpris")]
|
||||||
let mpris_manager = Arc::new(mpris::MprisManager::new(spotify.clone(), queue.clone()));
|
let mpris_manager = Arc::new(mpris::MprisManager::new(spotify.clone(), queue.clone()));
|
||||||
|
|||||||
@@ -20,19 +20,17 @@ pub struct Queue {
|
|||||||
random_order: RwLock<Option<Vec<usize>>>,
|
random_order: RwLock<Option<Vec<usize>>>,
|
||||||
current_track: RwLock<Option<usize>>,
|
current_track: RwLock<Option<usize>>,
|
||||||
repeat: RwLock<RepeatSetting>,
|
repeat: RwLock<RepeatSetting>,
|
||||||
notify: bool,
|
|
||||||
spotify: Arc<Spotify>,
|
spotify: Arc<Spotify>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Queue {
|
impl Queue {
|
||||||
pub fn new(spotify: Arc<Spotify>, notify: bool) -> Queue {
|
pub fn new(spotify: Arc<Spotify>) -> Queue {
|
||||||
let q = Queue {
|
let q = Queue {
|
||||||
queue: Arc::new(RwLock::new(Vec::new())),
|
queue: Arc::new(RwLock::new(Vec::new())),
|
||||||
spotify,
|
spotify,
|
||||||
current_track: RwLock::new(None),
|
current_track: RwLock::new(None),
|
||||||
repeat: RwLock::new(RepeatSetting::None),
|
repeat: RwLock::new(RepeatSetting::None),
|
||||||
random_order: RwLock::new(None),
|
random_order: RwLock::new(None),
|
||||||
notify,
|
|
||||||
};
|
};
|
||||||
q.set_repeat(q.spotify.repeat);
|
q.set_repeat(q.spotify.repeat);
|
||||||
q.set_shuffle(q.spotify.shuffle);
|
q.set_shuffle(q.spotify.shuffle);
|
||||||
@@ -218,7 +216,7 @@ impl Queue {
|
|||||||
let mut current = self.current_track.write().unwrap();
|
let mut current = self.current_track.write().unwrap();
|
||||||
current.replace(index);
|
current.replace(index);
|
||||||
self.spotify.update_track();
|
self.spotify.update_track();
|
||||||
if self.notify {
|
if self.spotify.cfg.notify.unwrap_or(false) {
|
||||||
Notification::new()
|
Notification::new()
|
||||||
.summary(&track.to_string())
|
.summary(&track.to_string())
|
||||||
.show()
|
.show()
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ pub enum PlayerEvent {
|
|||||||
pub struct Spotify {
|
pub struct Spotify {
|
||||||
events: EventManager,
|
events: EventManager,
|
||||||
credentials: Credentials,
|
credentials: Credentials,
|
||||||
cfg: config::Config,
|
pub cfg: config::Config,
|
||||||
status: RwLock<PlayerEvent>,
|
status: RwLock<PlayerEvent>,
|
||||||
api: RwLock<SpotifyAPI>,
|
api: RwLock<SpotifyAPI>,
|
||||||
elapsed: RwLock<Option<Duration>>,
|
elapsed: RwLock<Option<Duration>>,
|
||||||
|
|||||||
Reference in New Issue
Block a user