-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: try to support a mini notification widget
- Loading branch information
1 parent
0b8aa69
commit e77fb43
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
//! # D-Bus interface proxy for: `org.freedesktop.Notifications` | ||
//! | ||
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data. | ||
//! Source: `Interface '/org/freedesktop/Notifications' from service 'org.freedesktop.Notifications' on system bus`. | ||
//! | ||
//! 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::PeerProxy`] | ||
//! * [`zbus::fdo::IntrospectableProxy`] | ||
//! * [`zbus::fdo::PropertiesProxy`] | ||
//! | ||
//! 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::{interface, object_server::SignalContext, zvariant::OwnedValue}; | ||
|
||
const NOTIFICATION_DELTED_BY_EXPIRED: u32 = 1; | ||
Check warning on line 24 in src/notifications.rs GitHub Actions / build
|
||
const NOTIFICATION_DELTED_BY_USER: u32 = 2; | ||
Check warning on line 25 in src/notifications.rs GitHub Actions / build
|
||
const NOTIFICATION_CLOSED_BY_DBUS: u32 = 3; | ||
const NOTIFICATION_COLSED_BY_UNKNOWN_REASON: u32 = 4; | ||
Check warning on line 27 in src/notifications.rs GitHub Actions / build
|
||
|
||
pub struct NotifyUnit { | ||
app_name: String, | ||
id: u32, | ||
icon: String, | ||
summery: String, | ||
actions: Vec<String>, | ||
timeout: i32, | ||
} | ||
|
||
pub struct LaLaMako { | ||
units: Vec<NotifyUnit> | ||
} | ||
|
||
#[interface(name = "org.freedesktop.Notifications")] | ||
impl LaLaMako { | ||
// CloseNotification method | ||
async fn close_notification(&mut self, id: u32) -> zbus::fdo::Result<()> { | ||
Ok(()) | ||
} | ||
|
||
/// GetCapabilities method | ||
fn get_capabilities(&self) -> Vec<String> { | ||
vec![ | ||
"body".to_owned(), | ||
"body-markup".to_owned(), | ||
"actions".to_owned(), | ||
"icon-static".to_owned(), | ||
"x-canonical-private-synchronous".to_owned(), | ||
"x-dunst-stack-tag".to_owned(), | ||
] | ||
} | ||
|
||
/// GetServerInformation method | ||
fn get_server_information(&self) -> (String, String, String, String) { | ||
( | ||
"LaLaMako".to_owned(), | ||
"waycrate".to_owned(), | ||
env!("CARGO_PKG_VERSION").to_owned(), | ||
env!("CARGO_PKG_VERSION_PATCH").to_owned(), | ||
) | ||
} | ||
|
||
// Notify method | ||
#[allow(clippy::too_many_arguments)] | ||
fn notify( | ||
&mut self, | ||
app_name: &str, | ||
id: u32, | ||
icon: &str, | ||
summery: &str, | ||
body: &str, | ||
actions: Vec<&str>, | ||
hints: std::collections::HashMap<&str, OwnedValue>, | ||
timeout: i32, | ||
) -> zbus::fdo::Result<u32> { | ||
Ok(0) | ||
} | ||
|
||
#[zbus(signal)] | ||
async fn action_invoked( | ||
&self, | ||
ctx: &SignalContext<'_>, | ||
id: u32, | ||
action_key: &str, | ||
) -> zbus::Result<()>; | ||
|
||
// NotificationClosed signal | ||
#[zbus(signal)] | ||
async fn notification_closed( | ||
&self, | ||
ctx: &SignalContext<'_>, | ||
id: u32, | ||
reason: u32, | ||
) -> zbus::Result<()>; | ||
} |