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
|
cargo
|
||||||
rustfmt
|
rustfmt
|
||||||
rustc
|
rustc
|
||||||
|
libnotify
|
||||||
];
|
];
|
||||||
|
|
||||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
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 std::error::Error;
|
||||||
use zbus::{dbus_interface, ConnectionBuilder};
|
use zbus::{Connection, zvariant::{DeserializeDict, SerializeDict, Type}};
|
||||||
|
use zbus::dbus_interface;
|
||||||
|
|
||||||
struct NotifManager {
|
struct NotifManager {
|
||||||
next_id: u32,
|
next_id: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(DeserializeDict, SerializeDict, Type)]
|
||||||
|
#[zvariant(signature = "dict")]
|
||||||
|
struct Hints {
|
||||||
|
category: Option<String>,
|
||||||
|
urgency: Option<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
#[dbus_interface(name = "org.freedesktop.Notifications")]
|
#[dbus_interface(name = "org.freedesktop.Notifications")]
|
||||||
impl NotifManager {
|
impl NotifManager {
|
||||||
fn notify(
|
fn notify(
|
||||||
@@ -14,25 +22,41 @@ impl NotifManager {
|
|||||||
app_icon: &str,
|
app_icon: &str,
|
||||||
summary: &str,
|
summary: &str,
|
||||||
body: &str,
|
body: &str,
|
||||||
// actions: as,
|
actions: Vec<&str>,
|
||||||
// hints: a{sv},
|
hints: Hints,
|
||||||
expire_timeout: i32,
|
expire_timeout: i32,
|
||||||
) -> u32 {
|
) -> u32 {
|
||||||
self.next_id += 1;
|
self.next_id += 1;
|
||||||
println!("{}: {}", summary, body);
|
println!("{}: {}", summary, body);
|
||||||
self.next_id
|
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]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn Error>> {
|
async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
let connection = Connection::session().await?;
|
||||||
let manager = NotifManager { next_id: 0 };
|
let manager = NotifManager { next_id: 0 };
|
||||||
let _ = ConnectionBuilder::session()?
|
|
||||||
.name("org.freedesktop.Notifications")?
|
connection
|
||||||
.serve_at("/org/freedesktop/Notifications", manager)?
|
.object_server()
|
||||||
.build()
|
.at("/org/freedesktop/Notifications", manager)
|
||||||
|
.await?;
|
||||||
|
connection
|
||||||
|
.request_name("org.freedesktop.Notifications")
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
pending::<()>().await;
|
loop {}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user