]> git.r.bdr.sh - rbdr/lyricli/blame - src/sources/dbus.rs
Update dependencies
[rbdr/lyricli] / src / sources / dbus.rs
CommitLineData
040b91a7 1use mpris::PlayerFinder;
4064639d 2use std::io::Result;
040b91a7
RBR
3
4use crate::Track;
5
6use super::LyricsSource;
7
8pub struct Dbus;
9
10impl Dbus {
11 pub fn new() -> Self {
12 Dbus
13 }
14}
15
16impl LyricsSource for Dbus {
040b91a7
RBR
17 fn name(&self) -> String {
18 "dbus".to_string()
19 }
20
21 fn current_track(&self) -> Option<Track> {
4064639d 22 let player = PlayerFinder::new().ok()?.find_active().ok()?;
040b91a7
RBR
23
24 let metadata = player.get_metadata().ok()?;
25 let name = metadata.title()?.to_string();
26 let artists = metadata.artists()?;
27 let artist = artists.get(0)?.to_string();
28
4064639d 29 Some(Track { name, artist })
040b91a7
RBR
30 }
31
32 fn disable(&self) -> Result<()> {
33 Ok(())
34 }
35
36 fn enable(&self) -> Result<()> {
37 Ok(())
38 }
39
40 fn reset(&self) -> Result<()> {
41 Ok(())
42 }
43}