Implement suspend with logind

This commit is contained in:
Jeremy Soller 2023-11-29 08:02:14 -07:00
parent 5d0999df83
commit 13e3dcd911
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
5 changed files with 58 additions and 1 deletions

20
src/logind.rs Normal file
View file

@ -0,0 +1,20 @@
use logind_zbus::manager::ManagerProxy;
use zbus::{Connection, Result};
pub async fn power_off() -> Result<()> {
let connection = Connection::system().await?;
let manager = ManagerProxy::new(&connection).await?;
manager.reboot(false).await
}
pub async fn reboot() -> Result<()> {
let connection = Connection::system().await?;
let manager = ManagerProxy::new(&connection).await?;
manager.reboot(false).await
}
pub async fn suspend() -> Result<()> {
let connection = Connection::system().await?;
let manager = ManagerProxy::new(&connection).await?;
manager.suspend(false).await
}