diff --git a/Cargo.lock b/Cargo.lock index 05af74d..112c795 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1672,7 +1672,7 @@ dependencies = [ [[package]] name = "iced_layershell" version = "0.4.0-rc1" -source = "git+https://github.com/waycrate/exwlshelleventloop#9d133283359b72fbd2102483ae7d282273dd098d" +source = "git+https://github.com/waycrate/exwlshelleventloop#23afc29065769e335553261eab0ed88654344138" dependencies = [ "futures", "iced", @@ -1984,7 +1984,7 @@ dependencies = [ [[package]] name = "layershellev" version = "0.4.0-rc1" -source = "git+https://github.com/waycrate/exwlshelleventloop#9d133283359b72fbd2102483ae7d282273dd098d" +source = "git+https://github.com/waycrate/exwlshelleventloop#23afc29065769e335553261eab0ed88654344138" dependencies = [ "bitflags 2.6.0", "log", @@ -3966,7 +3966,7 @@ dependencies = [ [[package]] name = "waycrate_xkbkeycode" version = "0.4.0-rc1" -source = "git+https://github.com/waycrate/exwlshelleventloop#9d133283359b72fbd2102483ae7d282273dd098d" +source = "git+https://github.com/waycrate/exwlshelleventloop#23afc29065769e335553261eab0ed88654344138" dependencies = [ "bitflags 2.6.0", "log", diff --git a/lala_bar/src/main.rs b/lala_bar/src/main.rs index 51e2b87..32a5275 100644 --- a/lala_bar/src/main.rs +++ b/lala_bar/src/main.rs @@ -7,7 +7,7 @@ use iced_layershell::actions::{ LayershellCustomActionsWithIdAndInfo, LayershellCustomActionsWithInfo, }; use launcher::{LaunchMessage, Launcher}; -use notification_iced::{start_server, NotifyMessage, NotifyUnit}; +use notification_iced::{start_server, NotifyMessage, NotifyUnit, VersionInfo}; use zbus_mpirs::ServiceInfo; use iced_layershell::reexport::{Anchor, KeyboardInteractivity, Layer, NewLayerShellSettings}; @@ -632,7 +632,26 @@ impl MultiApplication for LalaMusicBar { iced::time::every(std::time::Duration::from_secs(5)).map(|_| Message::UpdateBalance), iced::event::listen() .map(|event| Message::LauncherInfo(LaunchMessage::IcedEvent(event))), - iced::subscription::channel(std::any::TypeId::of::<()>(), 100, start_server), + iced::subscription::channel(std::any::TypeId::of::<()>(), 100, |sender| async { + start_server( + sender, + 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(), + ], + VersionInfo { + name: "LaLaMako".to_owned(), + vendor: "waycrate".to_owned(), + version: env!("CARGO_PKG_VERSION").to_owned(), + spec_version: env!("CARGO_PKG_VERSION_PATCH").to_owned(), + }, + ) + .await + }), ]) } diff --git a/notification_iced/src/lib.rs b/notification_iced/src/lib.rs index f1e27f7..14ec457 100644 --- a/notification_iced/src/lib.rs +++ b/notification_iced/src/lib.rs @@ -52,8 +52,20 @@ pub struct NotifyUnit { pub timeout: i32, } +#[derive(Debug, Clone)] +pub struct VersionInfo { + pub name: String, + pub vendor: String, + pub version: String, + pub spec_version: String, +} + #[derive(Debug)] -pub struct LaLaMako + Send>(Sender); +pub struct LaLaMako + Send> { + capablities: Vec, + sender: Sender, + version: VersionInfo, +} #[interface(name = "org.freedesktop.Notifications")] impl + Send + 'static> LaLaMako { @@ -66,29 +78,30 @@ impl + Send + 'static> LaLaMako { self.notification_closed(&ctx, id, NOTIFICATION_DELETED_BY_USER) .await .ok(); - self.0.try_send(NotifyMessage::UnitRemove(id).into()).ok(); + self.sender + .try_send(NotifyMessage::UnitRemove(id).into()) + .ok(); Ok(()) } /// GetCapabilities method fn get_capabilities(&self) -> Vec { - 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(), - ] + self.capablities.clone() } /// GetServerInformation method fn get_server_information(&self) -> (String, String, String, String) { + let VersionInfo { + name, + vendor, + version, + spec_version, + } = &self.version; ( - "LaLaMako".to_owned(), - "waycrate".to_owned(), - env!("CARGO_PKG_VERSION").to_owned(), - env!("CARGO_PKG_VERSION_PATCH").to_owned(), + name.clone(), + vendor.clone(), + version.clone(), + spec_version.clone(), ) } @@ -105,7 +118,7 @@ impl + Send + 'static> LaLaMako { _hints: std::collections::HashMap<&str, OwnedValue>, timeout: i32, ) -> zbus::fdo::Result { - self.0 + self.sender .try_send( NotifyMessage::UnitAdd(NotifyUnit { app_name: app_name.to_string(), @@ -140,11 +153,22 @@ impl + Send + 'static> LaLaMako { ) -> zbus::Result<()>; } -pub async fn start_server + Send + 'static>(sender: Sender) -> Never { +pub async fn start_server + Send + 'static>( + sender: Sender, + capablities: Vec, + version: VersionInfo, +) -> Never { let _conn = async { ConnectionBuilder::session()? .name("org.freedesktop.Notifications")? - .serve_at("/org/freedesktop/Notifications", LaLaMako(sender))? + .serve_at( + "/org/freedesktop/Notifications", + LaLaMako { + sender, + capablities, + version, + }, + )? .build() .await }