Implement suspend with logind
This commit is contained in:
parent
5d0999df83
commit
13e3dcd911
5 changed files with 58 additions and 1 deletions
20
src/logind.rs
Normal file
20
src/logind.rs
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue