dbus: Take lid-inhibitor-locks on systemd systems
This commit is contained in:
parent
8648d4450e
commit
f2fc1e9480
5 changed files with 70 additions and 1 deletions
17
src/dbus/logind.rs
Normal file
17
src/dbus/logind.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use std::os::fd::OwnedFd;
|
||||
|
||||
use logind_zbus::manager::{InhibitType::HandleLidSwitch, ManagerProxyBlocking};
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
pub fn inhibit_lid() -> anyhow::Result<OwnedFd> {
|
||||
let conn = Connection::system()?;
|
||||
let proxy = ManagerProxyBlocking::new(&conn)?;
|
||||
let fd = proxy.inhibit(
|
||||
HandleLidSwitch,
|
||||
"cosmic-comp",
|
||||
"External output connected",
|
||||
"block",
|
||||
)?;
|
||||
|
||||
Ok(fd.into())
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ use calloop::{InsertError, LoopHandle, RegistrationToken};
|
|||
use std::collections::HashMap;
|
||||
use zbus::blocking::{fdo::DBusProxy, Connection};
|
||||
|
||||
#[cfg(feature = "systemd")]
|
||||
pub mod logind;
|
||||
mod power;
|
||||
|
||||
pub fn init(evlh: &LoopHandle<'static, State>) -> Result<Vec<RegistrationToken>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue