2023-11-29 08:02:14 -07:00
|
|
|
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?;
|
2024-04-05 06:21:40 -04:00
|
|
|
manager.power_off(false).await
|
2023-11-29 08:02:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|