Skip to content

Commit

Permalink
fix: try to support a mini notification widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Aug 8, 2024
1 parent 0b8aa69 commit e77fb43
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use iced_runtime::window::Action as WindowAction;
mod aximer;
mod launcher;
mod zbus_mpirs;
mod notifications;

type LaLaShellIdAction = LayershellCustomActionsWithIdAndInfo<LauncherInfo>;
type LalaShellAction = LayershellCustomActionsWithInfo<LauncherInfo>;
Expand Down
103 changes: 103 additions & 0 deletions src/notifications.rs
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

View workflow job for this annotation

GitHub Actions / build

"DELTED" should be "DELETED".

Check warning on line 24 in src/notifications.rs

View workflow job for this annotation

GitHub Actions / build

"DELTED" should be "DELETED".
const NOTIFICATION_DELTED_BY_USER: u32 = 2;

Check warning on line 25 in src/notifications.rs

View workflow job for this annotation

GitHub Actions / build

"DELTED" should be "DELETED".

Check warning on line 25 in src/notifications.rs

View workflow job for this annotation

GitHub Actions / build

"DELTED" should be "DELETED".
const NOTIFICATION_CLOSED_BY_DBUS: u32 = 3;
const NOTIFICATION_COLSED_BY_UNKNOWN_REASON: u32 = 4;

Check warning on line 27 in src/notifications.rs

View workflow job for this annotation

GitHub Actions / build

"COLSED" should be "CLOSED".

Check warning on line 27 in src/notifications.rs

View workflow job for this annotation

GitHub Actions / build

"COLSED" should be "CLOSED".

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<()>;
}

0 comments on commit e77fb43

Please sign in to comment.