slow progress
This commit is contained in:
parent
90ce8d4077
commit
71fa793480
@ -7,3 +7,4 @@ authors = ["candifloss <candifloss.cc>"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
zbus = "4.4.0"
|
zbus = "4.4.0"
|
||||||
# rson_rs = "0.2.1"
|
# rson_rs = "0.2.1"
|
||||||
|
tokio = "1.39.3"
|
31
src/main.rs
31
src/main.rs
@ -1,12 +1,24 @@
|
|||||||
use zbus::blocking::Connection;
|
//use zbus::blocking::Connection;
|
||||||
|
use zbus::Connection;
|
||||||
use zbus::fdo::Result;
|
use zbus::fdo::Result;
|
||||||
use zbus::Message;
|
use zbus::Message;
|
||||||
use zbus::MatchRule;
|
use zbus::MatchRule;
|
||||||
|
use zbus::blocking::Proxy;
|
||||||
|
use zbus::MessageStream;
|
||||||
|
//use futures_util::stream::TryStreamExt;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
// Establish a connection to the session bus
|
// Establish a connection to the session bus
|
||||||
let connection = Connection::session()?;
|
let connection = Connection::session()?;
|
||||||
|
|
||||||
|
// Proxy
|
||||||
|
let prox = Proxy::new(
|
||||||
|
&connection,
|
||||||
|
"org.freedesktop.Notifications", // Service/Bus name
|
||||||
|
"/org/freedesktop/Notifications", // Object path
|
||||||
|
"org.freedesktop.Notifications", // Interface name
|
||||||
|
)?;
|
||||||
|
|
||||||
// Define a match rule for the notifications
|
// Define a match rule for the notifications
|
||||||
let match_rule = MatchRule::builder()
|
let match_rule = MatchRule::builder()
|
||||||
.msg_type(zbus::MessageType::Signal)
|
.msg_type(zbus::MessageType::Signal)
|
||||||
@ -15,15 +27,22 @@ fn main() -> Result<()> {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Add the match rule to the connection
|
// Add the match rule to the connection
|
||||||
connection.add_match(match_rule)?;
|
//connection.add_match(match_rule)?;
|
||||||
|
|
||||||
|
let mut stream = MessageStream::from(connection);
|
||||||
|
while let Some(msg) = stream.body? {
|
||||||
|
println!("Got message: {}", msg);
|
||||||
|
}
|
||||||
// Process notifications
|
// Process notifications
|
||||||
loop {
|
/*loop {
|
||||||
let message = connection.receive_message()?;
|
/*
|
||||||
|
let message = connection.receive_signal()?;
|
||||||
if let Some(member) = message.member() {
|
if let Some(member) = message.member() {
|
||||||
if member.as_str() == "Notify" {
|
if member.as_str() == "Notify" {
|
||||||
println!("Received a notification: {:?}", message);
|
println!("Received a notification: {:?}", message);
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
}
|
|
||||||
|
}*/
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
96
src/notif.xml
Normal file
96
src/notif.xml
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||||
|
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||||
|
<!-- GDBus 2.80.0 -->
|
||||||
|
<node>
|
||||||
|
<interface name="org.freedesktop.DBus.Properties">
|
||||||
|
<method name="Get">
|
||||||
|
<arg type="s" name="interface_name" direction="in"/>
|
||||||
|
<arg type="s" name="property_name" direction="in"/>
|
||||||
|
<arg type="v" name="value" direction="out"/>
|
||||||
|
</method>
|
||||||
|
<method name="GetAll">
|
||||||
|
<arg type="s" name="interface_name" direction="in"/>
|
||||||
|
<arg type="a{sv}" name="properties" direction="out"/>
|
||||||
|
</method>
|
||||||
|
<method name="Set">
|
||||||
|
<arg type="s" name="interface_name" direction="in"/>
|
||||||
|
<arg type="s" name="property_name" direction="in"/>
|
||||||
|
<arg type="v" name="value" direction="in"/>
|
||||||
|
</method>
|
||||||
|
<signal name="PropertiesChanged">
|
||||||
|
<arg type="s" name="interface_name"/>
|
||||||
|
<arg type="a{sv}" name="changed_properties"/>
|
||||||
|
<arg type="as" name="invalidated_properties"/>
|
||||||
|
</signal>
|
||||||
|
</interface>
|
||||||
|
<interface name="org.freedesktop.DBus.Introspectable">
|
||||||
|
<method name="Introspect">
|
||||||
|
<arg type="s" name="xml_data" direction="out"/>
|
||||||
|
</method>
|
||||||
|
</interface>
|
||||||
|
<interface name="org.freedesktop.DBus.Peer">
|
||||||
|
<method name="Ping"/>
|
||||||
|
<method name="GetMachineId">
|
||||||
|
<arg type="s" name="machine_uuid" direction="out"/>
|
||||||
|
</method>
|
||||||
|
</interface>
|
||||||
|
<interface name="org.freedesktop.Notifications">
|
||||||
|
<method name="Notify">
|
||||||
|
<arg type="s" name="arg_0" direction="in">
|
||||||
|
</arg>
|
||||||
|
<arg type="u" name="arg_1" direction="in">
|
||||||
|
</arg>
|
||||||
|
<arg type="s" name="arg_2" direction="in">
|
||||||
|
</arg>
|
||||||
|
<arg type="s" name="arg_3" direction="in">
|
||||||
|
</arg>
|
||||||
|
<arg type="s" name="arg_4" direction="in">
|
||||||
|
</arg>
|
||||||
|
<arg type="as" name="arg_5" direction="in">
|
||||||
|
</arg>
|
||||||
|
<arg type="a{sv}" name="arg_6" direction="in">
|
||||||
|
</arg>
|
||||||
|
<arg type="i" name="arg_7" direction="in">
|
||||||
|
</arg>
|
||||||
|
<arg type="u" name="arg_8" direction="out">
|
||||||
|
</arg>
|
||||||
|
</method>
|
||||||
|
<method name="CloseNotification">
|
||||||
|
<arg type="u" name="arg_0" direction="in">
|
||||||
|
</arg>
|
||||||
|
</method>
|
||||||
|
<method name="GetCapabilities">
|
||||||
|
<arg type="as" name="arg_0" direction="out">
|
||||||
|
</arg>
|
||||||
|
</method>
|
||||||
|
<method name="GetServerInformation">
|
||||||
|
<arg type="s" name="arg_0" direction="out">
|
||||||
|
</arg>
|
||||||
|
<arg type="s" name="arg_1" direction="out">
|
||||||
|
</arg>
|
||||||
|
<arg type="s" name="arg_2" direction="out">
|
||||||
|
</arg>
|
||||||
|
<arg type="s" name="arg_3" direction="out">
|
||||||
|
</arg>
|
||||||
|
</method>
|
||||||
|
<signal name="NotificationClosed">
|
||||||
|
<arg type="u" name="arg_0">
|
||||||
|
</arg>
|
||||||
|
<arg type="u" name="arg_1">
|
||||||
|
</arg>
|
||||||
|
</signal>
|
||||||
|
<signal name="ActionInvoked">
|
||||||
|
<arg type="u" name="arg_0">
|
||||||
|
</arg>
|
||||||
|
<arg type="s" name="arg_1">
|
||||||
|
</arg>
|
||||||
|
</signal>
|
||||||
|
<signal name="ActivationToken">
|
||||||
|
<arg type="u" name="arg_0">
|
||||||
|
</arg>
|
||||||
|
<arg type="s" name="arg_1">
|
||||||
|
</arg>
|
||||||
|
</signal>
|
||||||
|
</interface>
|
||||||
|
</node>
|
||||||
|
|
59
src/notifications.rs
Normal file
59
src/notifications.rs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
//! # D-Bus interface proxy for: `org.freedesktop.Notifications`
|
||||||
|
//!
|
||||||
|
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
|
||||||
|
//! Source: `notif.xml`.
|
||||||
|
//!
|
||||||
|
//! You may prefer to adapt it, instead of using it verbatim.
|
||||||
|
//!
|
||||||
|
//! More information can be found in the [Writing a client proxy] section of the zbus
|
||||||
|
//! documentation.
|
||||||
|
//!
|
||||||
|
//! This type implements the [D-Bus standard interfaces], (`org.freedesktop.DBus.*`) for which the
|
||||||
|
//! following zbus API can be used:
|
||||||
|
//!
|
||||||
|
//! * [`zbus::fdo::PropertiesProxy`]
|
||||||
|
//! * [`zbus::fdo::IntrospectableProxy`]
|
||||||
|
//! * [`zbus::fdo::PeerProxy`]
|
||||||
|
//!
|
||||||
|
//! Consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||||
|
//!
|
||||||
|
//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html
|
||||||
|
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces,
|
||||||
|
use zbus::proxy;
|
||||||
|
#[proxy(interface = "org.freedesktop.Notifications", assume_defaults = true)]
|
||||||
|
trait Notifications {
|
||||||
|
/// CloseNotification method
|
||||||
|
fn close_notification(&self, arg_0: u32) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// GetCapabilities method
|
||||||
|
fn get_capabilities(&self) -> zbus::Result<Vec<String>>;
|
||||||
|
|
||||||
|
/// GetServerInformation method
|
||||||
|
fn get_server_information(&self) -> zbus::Result<(String, String, String, String)>;
|
||||||
|
|
||||||
|
/// Notify method
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
fn notify(
|
||||||
|
&self,
|
||||||
|
arg_0: &str,
|
||||||
|
arg_1: u32,
|
||||||
|
arg_2: &str,
|
||||||
|
arg_3: &str,
|
||||||
|
arg_4: &str,
|
||||||
|
arg_5: &[&str],
|
||||||
|
arg_6: std::collections::HashMap<&str, &zbus::zvariant::Value<'_>>,
|
||||||
|
arg_7: i32,
|
||||||
|
) -> zbus::Result<u32>;
|
||||||
|
|
||||||
|
/// ActionInvoked signal
|
||||||
|
#[zbus(signal)]
|
||||||
|
fn action_invoked(&self, arg_0: u32, arg_1: &str) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// ActivationToken signal
|
||||||
|
#[zbus(signal)]
|
||||||
|
fn activation_token(&self, arg_0: u32, arg_1: &str) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// NotificationClosed signal
|
||||||
|
#[zbus(signal)]
|
||||||
|
fn notification_closed(&self, arg_0: u32, arg_1: u32) -> zbus::Result<()>;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user