From baedbc7eac0f100d5e41f9213794c795fdbd2e5a Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Sat, 17 Oct 2020 16:36:03 -0500 Subject: [PATCH] Listen for changed spotify properties --- .gitignore | 1 + Cargo.lock | 39 +++++++++++++++++++++++++++++++++++++++ Cargo.toml | 10 ++++++++++ src/main.rs | 25 +++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..fd6c2ab --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,39 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "dbus" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22c08adfeb70c940c14d8af988fa854dcb5529e6141f2397e4e0fa4c9375d094" +dependencies = [ + "libc", + "libdbus-sys", +] + +[[package]] +name = "libc" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" + +[[package]] +name = "libdbus-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc12a3bc971424edbbf7edaf6e5740483444db63aa8e23d3751ff12a30f306f0" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "pkg-config" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[package]] +name = "xsetrootd" +version = "0.1.0" +dependencies = [ + "dbus", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..9f14b5c --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "xsetrootd" +version = "0.1.0" +authors = ["Jacob Casper "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +dbus = "0.9.0" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..df3b54e --- /dev/null +++ b/src/main.rs @@ -0,0 +1,25 @@ +use dbus::blocking::stdintf::org_freedesktop_dbus::PropertiesPropertiesChanged; +use dbus::blocking::Connection; +use dbus::message::Message; +use std::time::Duration; + +fn main() -> Result<(), Box> { + let conn = Connection::new_session()?; + + let proxy = conn.with_proxy( + "org.mpris.MediaPlayer2.spotify", + "/org/mpris/MediaPlayer2", + Duration::from_millis(5000), + ); + + let _ = proxy.match_signal( + |pc: PropertiesPropertiesChanged, _: &Connection, _: &Message| { + println! {"dumping {:#x?}", pc.changed_properties["Metadata"]}; + true + }, + ); + + loop { + conn.process(Duration::from_millis(1000))?; + } +} -- 2.20.1