D-Bus session service, currently only used to exit.

This commit is contained in:
Lucy 2022-07-22 11:48:03 -04:00
parent d13768607c
commit 2bda93e030
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1
4 changed files with 61 additions and 21 deletions

21
src/service.rs Normal file
View file

@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-only
use tokio::sync::oneshot;
use zbus::dbus_interface;
pub struct SessionService {
pub exit_tx: Option<oneshot::Sender<()>>,
}
#[dbus_interface(name = "com.system76.CosmicSession")]
impl SessionService {
async fn exit(&mut self) {
match self.exit_tx.take() {
Some(tx) => {
tx.send(()).ok();
}
None => {
warn!("previously failed to properly exit session");
}
}
}
}