diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2024-03-16 11:01:41 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2024-03-16 11:01:41 +0100 |
| commit | 040b91a7a5b085f8aa0bec3580bf7d68450e6fc9 (patch) | |
| tree | f27088c562fea977c9cbb97ffde3e81590db91fa /src/sources/dbus.rs | |
| parent | 616cee0382cb0b9e287d1037ec82813aa859c1a0 (diff) | |
Add linux config
Diffstat (limited to 'src/sources/dbus.rs')
| -rw-r--r-- | src/sources/dbus.rs | 48 |
1 files changed, 48 insertions, 0 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(()) + } +} |