diff --git a/src/core/notification.rs b/src/core/notification.rs index 66407f8..5c0e648 100644 --- a/src/core/notification.rs +++ b/src/core/notification.rs @@ -1,6 +1,23 @@ +use gtk::gio; +use gtk::prelude::*; + use super::database::Database; use super::security; +/// Send a desktop notification via gio. +pub fn send_system_notification( + app: &gio::Application, + id: &str, + title: &str, + body: &str, + priority: gio::NotificationPriority, +) { + let notification = gio::Notification::new(title); + notification.set_body(Some(body)); + notification.set_priority(priority); + app.send_notification(Some(id), ¬ification); +} + /// A CVE notification to send to the user. #[derive(Debug, Clone)] pub struct CveNotification { diff --git a/src/ui/detail_view.rs b/src/ui/detail_view.rs index 2fe2971..e4501fa 100644 --- a/src/ui/detail_view.rs +++ b/src/ui/detail_view.rs @@ -11,6 +11,7 @@ use crate::core::footprint; use crate::core::fuse::{self, FuseStatus}; use crate::core::integrator; use crate::core::launcher::{self, SandboxMode}; +use crate::core::notification; use crate::core::security; use crate::core::updater; use crate::core::wayland::{self, WaylandStatus}; @@ -148,6 +149,15 @@ pub fn build_detail_page(record: &AppImageRecord, db: &Rc) -> adw::Nav Ok(launcher::LaunchResult::Crashed { exit_code, stderr, method }) => { log::error!("App crashed on launch (exit {}, method: {}): {}", exit_code.unwrap_or(-1), method.as_str(), stderr); widgets::show_crash_dialog(&btn_ref, &app_name, exit_code, &stderr); + if let Some(app) = gtk::gio::Application::default() { + notification::send_system_notification( + &app, + &format!("crash-{}", record_id), + &format!("{} crashed", app_name), + &stderr.chars().take(200).collect::(), + gtk::gio::NotificationPriority::Urgent, + ); + } } Ok(launcher::LaunchResult::Failed(msg)) => { log::error!("Failed to launch: {}", msg);