mirror of
https://github.com/zoriya/fldsmdfr.git
synced 2025-12-06 06:26:15 +00:00
Adding required methods
This commit is contained in:
@@ -4,6 +4,7 @@ pkgs.mkShell {
|
||||
cargo
|
||||
rustfmt
|
||||
rustc
|
||||
libnotify
|
||||
];
|
||||
|
||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
|
||||
44
src/main.rs
44
src/main.rs
@@ -1,10 +1,18 @@
|
||||
use std::{error::Error, future::pending};
|
||||
use zbus::{dbus_interface, ConnectionBuilder};
|
||||
use std::error::Error;
|
||||
use zbus::{Connection, zvariant::{DeserializeDict, SerializeDict, Type}};
|
||||
use zbus::dbus_interface;
|
||||
|
||||
struct NotifManager {
|
||||
next_id: u32,
|
||||
}
|
||||
|
||||
#[derive(DeserializeDict, SerializeDict, Type)]
|
||||
#[zvariant(signature = "dict")]
|
||||
struct Hints {
|
||||
category: Option<String>,
|
||||
urgency: Option<u8>,
|
||||
}
|
||||
|
||||
#[dbus_interface(name = "org.freedesktop.Notifications")]
|
||||
impl NotifManager {
|
||||
fn notify(
|
||||
@@ -14,25 +22,41 @@ impl NotifManager {
|
||||
app_icon: &str,
|
||||
summary: &str,
|
||||
body: &str,
|
||||
// actions: as,
|
||||
// hints: a{sv},
|
||||
actions: Vec<&str>,
|
||||
hints: Hints,
|
||||
expire_timeout: i32,
|
||||
) -> u32 {
|
||||
self.next_id += 1;
|
||||
println!("{}: {}", summary, body);
|
||||
self.next_id
|
||||
}
|
||||
|
||||
fn get_capabilities(&self) -> Vec<&str> {
|
||||
vec!["body", "actions", "body-images", "persistence", "icon-static"]
|
||||
}
|
||||
|
||||
fn get_server_information(&self) -> [&str; 4] {
|
||||
[
|
||||
env!("CARGO_PKG_NAME"),
|
||||
"zoriya",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
"1.2",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let connection = Connection::session().await?;
|
||||
let manager = NotifManager { next_id: 0 };
|
||||
let _ = ConnectionBuilder::session()?
|
||||
.name("org.freedesktop.Notifications")?
|
||||
.serve_at("/org/freedesktop/Notifications", manager)?
|
||||
.build()
|
||||
|
||||
connection
|
||||
.object_server()
|
||||
.at("/org/freedesktop/Notifications", manager)
|
||||
.await?;
|
||||
connection
|
||||
.request_name("org.freedesktop.Notifications")
|
||||
.await?;
|
||||
|
||||
pending::<()>().await;
|
||||
Ok(())
|
||||
loop {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user