diff --git a/cosmic-applet-notifications/src/main.rs b/cosmic-applet-notifications/src/main.rs index 8099be3e..9e85289a 100644 --- a/cosmic-applet-notifications/src/main.rs +++ b/cosmic-applet-notifications/src/main.rs @@ -183,7 +183,7 @@ impl Application for Notifications { .min_width(1.0) .max_width(300.0) .min_height(100.0) - .max_height(600.0); + .max_height(900.0); get_popup(popup_settings) } } diff --git a/cosmic-applet-notifications/src/subscriptions/notifications.rs b/cosmic-applet-notifications/src/subscriptions/notifications.rs index 12633c79..dfb974bc 100644 --- a/cosmic-applet-notifications/src/subscriptions/notifications.rs +++ b/cosmic-applet-notifications/src/subscriptions/notifications.rs @@ -41,12 +41,25 @@ pub fn notifications() -> Subscription { std::thread::spawn(move || -> anyhow::Result<()> { let mut msg = String::new(); - std::io::stdin().read_line(&mut msg)?; - let raw_fd = msg.trim().parse::()?; + + if let Err(err) = std::io::stdin().read_line(&mut msg) { + error!("Failed to read line from panel: {}", err); + anyhow::bail!("Failed to read line from panel"); + } + + info!("Received fd from panel: {}", msg); + let Ok(raw_fd) = msg.trim().parse::() else { + error!("Failed to parse fd from panel"); + anyhow::bail!("Failed to parse fd from panel"); + }; if raw_fd == 0 { + error!("Invalid fd received from panel"); anyhow::bail!("Invalid fd received from panel"); } - _ = tx.send(raw_fd); + if let Err(err) = tx.send(raw_fd) { + error!("Failed to send fd to main thread: {}", err); + anyhow::bail!("Failed to send fd to main thread"); + } Ok(()) }); @@ -122,6 +135,10 @@ pub fn notifications() -> Subscription { let mut lines = reader.lines(); while let Ok(Some(line)) = lines.next_line().await { + if line.is_empty() { + warn!("Received empty line from notification stream. The notification daemon probably crashed, so we will exit."); + std::process::exit(1); + } if let Ok(event) = ron::de::from_str::(line.as_str()) { if let Err(_err) = output.send(event).await { error!("Error sending event"); @@ -130,8 +147,8 @@ pub fn notifications() -> Subscription { error!("Failed to deserialize event from notification stream"); } } - warn!("Notification stream closed"); - state = State::Finished; + warn!("Notification stream closed. The notification daemon probably crashed, so we will exit."); + std::process::exit(1); } State::Finished => { let () = futures::future::pending().await;