From ee8ac99d9fa1f348065108b73297eebc8033e57e Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Thu, 17 Jul 2025 15:31:38 +0200 Subject: Use objc2, rename dbus to mpris, add swinsian --- src/sources/mpris.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/sources/mpris.rs (limited to 'src/sources/mpris.rs') diff --git a/src/sources/mpris.rs b/src/sources/mpris.rs new file mode 100644 index 0000000..69eb862 --- /dev/null +++ b/src/sources/mpris.rs @@ -0,0 +1,43 @@ +use mpris::PlayerFinder; +use std::io::Result; + +use crate::Track; + +use super::LyricsSource; + +pub struct Mpris; + +impl Mpris { + pub fn new() -> Self { + Mpris + } +} + +impl LyricsSource for Mpris { + fn name(&self) -> String { + "mpris".to_string() + } + + fn current_track(&self) -> Option { + 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(()) + } +} -- cgit