redbear-sessiond: emit SeatRemoved on shutdown

Completes the SeatNew/SeatRemoved pair from the prior commit. The
emit_seat_removed public method was added but not wired to any shutdown
path; this commit hooks it into wait_for_shutdown's return path so
subscribers (e.g. SDDM's LogindSeatManager) observe seat departure
before the D-Bus connection drops. SEAT_PATH is reused from main.rs's
existing constant rather than introducing a new placeholder string.
This commit is contained in:
2026-07-27 14:35:33 +09:00
parent ec8af52952
commit e6e4289113
@@ -205,6 +205,23 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
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(());
}