X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli/blobdiff_plain/44e7b4de4073e6dc25681bb2fa6977bf5869689a..d33e6d4dc5323513df30c598a56779b16448d595:/src/sources/mod.rs?ds=inline diff --git a/src/sources/mod.rs b/src/sources/mod.rs index 78f7499..47c25d0 100644 --- a/src/sources/mod.rs +++ b/src/sources/mod.rs @@ -1,32 +1,20 @@ -use std::io::{Result, Error, ErrorKind::Other}; +use std::io::{Error, ErrorKind::Other, Result}; #[cfg(target_os = "macos")] mod apple_music; #[cfg(target_os = "macos")] mod spotify; -// #[cfg(not(target_os = "macos"))] -// mod rhythmbox; -// #[cfg(not(target_os = "macos"))] -// mod quod_libe; -// #[cfg(not(target_os = "macos"))] -// mod strawberry; -// #[cfg(not(target_os = "macos"))] -// mod tauon; +#[cfg(target_os = "linux")] +mod dbus; #[cfg(target_os = "macos")] use apple_music::AppleMusic; #[cfg(target_os = "macos")] use spotify::Spotify; -// #[cfg(not(target_os = "macos"))] -// use rhythmbox::Rhythmbox; -// #[cfg(not(target_os = "macos"))] -// use quod_libet::QuodLibet; -// #[cfg(not(target_os = "macos"))] -// use strawberry::Strawberry; -// #[cfg(not(target_os = "macos"))] -// use tauon::Tauon; +#[cfg(target_os = "linux")] +use dbus::Dbus; use crate::Track; @@ -41,14 +29,17 @@ pub trait LyricsSource { } pub fn list() -> Vec { - available_sources().into_iter().map(|source| source.name()).collect() + available_sources() + .into_iter() + .map(|source| source.name()) + .collect() } pub fn enable(source_name: &String) -> Result<()> { let sources = available_sources(); for source in sources { if &source.name() == source_name { - return source.enable() + return source.enable(); } } Err(Error::new(Other, "No such source was available.")) @@ -58,7 +49,7 @@ pub fn disable(source_name: &String) -> Result<()> { let sources = available_sources(); for source in sources { if &source.name() == source_name { - return source.disable() + return source.disable(); } } Err(Error::new(Other, "No such source was available.")) @@ -68,7 +59,7 @@ pub fn reset(source_name: &String) -> Result<()> { let sources = available_sources(); for source in sources { if &source.name() == source_name { - return source.reset() + return source.reset(); } } Err(Error::new(Other, "No such source was available.")) @@ -81,7 +72,7 @@ pub fn get_track() -> Option { return Some(track); } } - return None + return None; } pub fn available_sources() -> Vec> { @@ -94,10 +85,7 @@ pub fn available_sources() -> Vec> { #[cfg(not(target_os = "macos"))] { - // sources.push(Box::new(Rhythmbox::new())); - // sources.push(Box::new(QuodLibet::new())); - // sources.push(Box::new(Strawberry::new())); - // sources.push(Box::new(Tauon::new())); + sources.push(Box::new(Dbus::new())); } sources