aboutsummaryrefslogtreecommitdiff
path: root/src/sources
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2024-03-16 11:01:41 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2024-03-16 11:01:41 +0100
commit040b91a7a5b085f8aa0bec3580bf7d68450e6fc9 (patch)
treef27088c562fea977c9cbb97ffde3e81590db91fa /src/sources
parent616cee0382cb0b9e287d1037ec82813aa859c1a0 (diff)
Add linux config
Diffstat (limited to 'src/sources')
-rw-r--r--src/sources/dbus.rs48
-rw-r--r--src/sources/mod.rs25
2 files changed, 53 insertions, 20 deletions
diff --git a/src/sources/dbus.rs b/src/sources/dbus.rs
new file mode 100644
index 0000000..57c5853
--- /dev/null
+++ b/src/sources/dbus.rs
@@ -0,0 +1,48 @@
+use std::io::Result;
+use mpris::PlayerFinder;
+
+use crate::Track;
+
+use super::LyricsSource;
+
+pub struct Dbus;
+
+impl Dbus {
+ pub fn new() -> Self {
+ Dbus
+ }
+}
+
+impl LyricsSource for Dbus {
+
+ fn name(&self) -> String {
+ "dbus".to_string()
+ }
+
+ fn current_track(&self) -> Option<Track> {
+ let player = PlayerFinder::new().ok()?
+ .find_active().ok()?;
+
+ let metadata = player.get_metadata().ok()?;
+ let name = metadata.title()?.to_string();
+ let artists = metadata.artists()?;
+ let artist = artists.get(0)?.to_string();
+
+ Some(Track {
+ name,
+ artist
+ })
+ }
+
+ fn disable(&self) -> Result<()> {
+ Ok(())
+ }
+
+ fn enable(&self) -> Result<()> {
+ Ok(())
+ }
+
+ fn reset(&self) -> Result<()> {
+ Ok(())
+ }
+}
diff --git a/src/sources/mod.rs b/src/sources/mod.rs
index 78f7499..087a87f 100644
--- a/src/sources/mod.rs
+++ b/src/sources/mod.rs
@@ -5,28 +5,16 @@ 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;
@@ -94,10 +82,7 @@ pub fn available_sources() -> Vec<Box<dyn LyricsSource>> {
#[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