Created
September 6, 2019 13:59
-
-
Save ammgws/57cf8d4d4442abf9d7d16282fb7028a8 to your computer and use it in GitHub Desktop.
Using dbus-rs (v0.6) to get value of new DBus property from the signal message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
extern crate dbus; | |
use dbus::{BusType, Connection, SignalArgs}; | |
use dbus::stdintf::org_freedesktop_dbus::PropertiesPropertiesChanged; | |
fn main() { | |
let c = Connection::get_private(BusType::Session).unwrap(); | |
let matched_signal = PropertiesPropertiesChanged::match_str(Some(&"localhost.statusbar.DBus".into()), Some(&"/localhost/statusbar/DBus/SoundDevice".into())); | |
c.add_match(&matched_signal).unwrap(); | |
loop { | |
for msg in c.incoming(1000) { | |
if let Some(signal) = PropertiesPropertiesChanged::from_message(&msg) { | |
let value = signal.changed_properties.get("Status").unwrap(); | |
let status = value.0.as_str().unwrap(); | |
println!("Status changed to: {}", &status); | |
} | |
} | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment