diff --git a/local/recipes/system/redbear-sessiond/source/src/main.rs b/local/recipes/system/redbear-sessiond/source/src/main.rs index 8357097b1a..35e5ae8a20 100644 --- a/local/recipes/system/redbear-sessiond/source/src/main.rs +++ b/local/recipes/system/redbear-sessiond/source/src/main.rs @@ -205,6 +205,23 @@ async fn run_daemon() -> Result<(), Box> { control::start_control_socket(runtime.clone(), shutdown_tx.clone()); tokio::spawn(acpi_watcher::watch_and_emit(connection.clone(), runtime.clone())); wait_for_shutdown(shutdown_rx).await?; + // Order: emit before drop so subscribers see SeatRemoved before the bus connection closes. + let seat_id = match runtime.read() { + Ok(runtime) => runtime.seat_id.clone(), + Err(_) => String::from("seat0"), + }; + let seat_path = + match zbus::zvariant::OwnedObjectPath::try_from(SEAT_PATH.to_owned()) { + Ok(p) => p, + Err(_) => { + eprintln!( + "redbear-sessiond: SEAT_PATH constant is not a valid D-Bus path; skipping SeatRemoved" + ); + drop(connection); + return Ok(()); + } + }; + manager_ref.emit_seat_removed(&seat_id, &seat_path).await; drop(connection); return Ok(()); }