]>
Commit | Line | Data |
---|---|---|
040b91a7 | 1 | use mpris::PlayerFinder; |
4064639d | 2 | use std::io::Result; |
040b91a7 RBR |
3 | |
4 | use crate::Track; | |
5 | ||
6 | use super::LyricsSource; | |
7 | ||
8 | pub struct Dbus; | |
9 | ||
10 | impl Dbus { | |
11 | pub fn new() -> Self { | |
12 | Dbus | |
13 | } | |
14 | } | |
15 | ||
16 | impl 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 | } |