From: Ruben Beltran del Rio Date: Sat, 16 Mar 2024 10:01:41 +0000 (+0100) Subject: Add linux config X-Git-Tag: 3.0.0~17 X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli/commitdiff_plain/040b91a7a5b085f8aa0bec3580bf7d68450e6fc9?ds=inline;hp=616cee0382cb0b9e287d1037ec82813aa859c1a0 Add linux config --- diff --git a/Cargo.lock b/Cargo.lock index 95c6f91..2800b09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -172,7 +172,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.0", ] [[package]] @@ -181,9 +181,9 @@ version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", - "quote", + "quote 1.0.35", "syn 2.0.52", ] @@ -288,10 +288,67 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ - "quote", + "quote 1.0.35", "syn 2.0.52", ] +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote 1.0.35", + "strsim 0.10.0", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote 1.0.35", + "syn 1.0.109", +] + +[[package]] +name = "dbus" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b" +dependencies = [ + "libc", + "libdbus-sys", + "winapi", +] + +[[package]] +name = "derive_is_enum_variant" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ac8859845146979953797f03cc5b282fb4396891807cdb3d04929a88418197" +dependencies = [ + "heck 0.3.3", + "quote 0.3.15", + "syn 0.11.11", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -299,7 +356,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "proc-macro2", - "quote", + "quote 1.0.35", "syn 1.0.109", ] @@ -333,6 +390,17 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum-kinds" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e40a16955681d469ab3da85aaa6b42ff656b3c67b52e1d8d3dd36afe97fd462" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "syn 1.0.109", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -387,7 +455,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", - "quote", + "quote 1.0.35", "syn 2.0.52", ] @@ -412,6 +480,27 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "from_variants" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e859c8f2057687618905dbe99fc76e836e0a69738865ef90e46fc214a41bbf2" +dependencies = [ + "from_variants_impl", +] + +[[package]] +name = "from_variants_impl" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55a5e644a80e6d96b2b4910fa7993301d7b7926c045b475b62202b20a36ce69e" +dependencies = [ + "darling", + "proc-macro2", + "quote 1.0.35", + "syn 1.0.109", +] + [[package]] name = "futf" version = "0.1.5" @@ -521,6 +610,15 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "heck" version = "0.4.1" @@ -543,7 +641,7 @@ dependencies = [ "mac", "markup5ever", "proc-macro2", - "quote", + "quote 1.0.35", "syn 1.0.109", ] @@ -618,6 +716,12 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -671,6 +775,15 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libdbus-sys" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72" +dependencies = [ + "pkg-config", +] + [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -700,6 +813,7 @@ dependencies = [ "clap", "cocoa", "libc", + "mpris", "objc", "objc_id", "percent-encoding", @@ -771,6 +885,19 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mpris" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cef955a7826b1e00e901a3652e7a895abd221fb4ab61547e7d0e4c235d7feb" +dependencies = [ + "dbus", + "derive_is_enum_variant", + "enum-kinds", + "from_variants", + "thiserror", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -860,7 +987,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", - "quote", + "quote 1.0.35", "syn 2.0.52", ] @@ -969,7 +1096,7 @@ dependencies = [ "phf_generator 0.11.2", "phf_shared 0.11.2", "proc-macro2", - "quote", + "quote 1.0.35", "syn 2.0.52", ] @@ -1030,6 +1157,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quote" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" + [[package]] name = "quote" version = "1.0.35" @@ -1241,7 +1374,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", - "quote", + "quote 1.0.35", "syn 2.0.52", ] @@ -1346,15 +1479,32 @@ dependencies = [ "phf_generator 0.10.0", "phf_shared 0.10.0", "proc-macro2", - "quote", + "quote 1.0.35", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strsim" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +[[package]] +name = "syn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +dependencies = [ + "quote 0.3.15", + "synom", + "unicode-xid", +] + [[package]] name = "syn" version = "1.0.109" @@ -1362,7 +1512,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", - "quote", + "quote 1.0.35", "unicode-ident", ] @@ -1373,7 +1523,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", - "quote", + "quote 1.0.35", "unicode-ident", ] @@ -1383,6 +1533,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +dependencies = [ + "unicode-xid", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -1427,6 +1586,26 @@ dependencies = [ "utf-8", ] +[[package]] +name = "thiserror" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "syn 2.0.52", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -1468,7 +1647,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", - "quote", + "quote 1.0.35", "syn 2.0.52", ] @@ -1548,12 +1727,24 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + [[package]] name = "unicode-width" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" + [[package]] name = "url" version = "2.5.0" @@ -1624,7 +1815,7 @@ dependencies = [ "log", "once_cell", "proc-macro2", - "quote", + "quote 1.0.35", "syn 2.0.52", "wasm-bindgen-shared", ] @@ -1647,7 +1838,7 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ - "quote", + "quote 1.0.35", "wasm-bindgen-macro-support", ] @@ -1658,7 +1849,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", - "quote", + "quote 1.0.35", "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -1680,6 +1871,28 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-sys" version = "0.48.0" @@ -1838,6 +2051,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", - "quote", + "quote 1.0.35", "syn 2.0.52", ] diff --git a/Cargo.toml b/Cargo.toml index ba316a9..cb0850d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,9 @@ objc = "0.2.7" cocoa = "0.25.0" objc_id = "0.1.1" +[target.'cfg(target_os = "linux")'.dependencies] +mpris = "2.0.1" + [profile.release] strip = true lto = true diff --git a/README.md b/README.md index 932cc02..f4d969a 100644 --- a/README.md +++ b/README.md @@ -59,4 +59,8 @@ make make -e profile=release ``` +### Additional Dependencies + +On linux you might need to install the libssl-dev and libdbus-dev + [genius_api_docs]: https://docs.genius.com/ diff --git a/src/configuration.rs b/src/configuration.rs index f678461..55443eb 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -8,7 +8,7 @@ use serde_json; const CONFIG_ENV_VARIABLE: &str = "LYRICLI_CONFIG_DIRECTORY"; const CONFIG_DEFAULT_LOCATION: &str = "XDG_CONFIG_HOME"; const CONFIG_FALLBACK_LOCATION: &str = ".config"; -const CONFIG_SUBDIRECTORY: &str = ".config"; +const CONFIG_SUBDIRECTORY: &str = "lyricli"; const CONFIG_FILENAME: &str = "lyricli.conf"; #[derive(Serialize, Deserialize, Debug)] @@ -55,7 +55,8 @@ impl Configuration { Configuration { enabled_sources: vec![ "apple_music".to_string(), - "spotify".to_string() + "spotify".to_string(), + "strawberry".to_string() ] } } 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 { + 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> { #[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