autocommit 2022-03-13 23:16:26 CET
This commit is contained in:
parent
a15a02a95c
commit
18806a38fb
13 changed files with 77 additions and 16 deletions
|
|
@ -4,6 +4,7 @@ use crate::{org, FALSE};
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::c;
|
||||
use crate::org::freedesktop::login1::seat::SwitchToReply;
|
||||
|
||||
const LOGIND_NAME: &str = "org.freedesktop.login1";
|
||||
const MANAGER_PATH: &str = "/org/freedesktop/login1";
|
||||
|
|
@ -22,7 +23,7 @@ pub enum LogindError {
|
|||
|
||||
pub struct Session {
|
||||
socket: Rc<DbusSocket>,
|
||||
_seat: String,
|
||||
seat: String,
|
||||
session_path: String,
|
||||
}
|
||||
|
||||
|
|
@ -52,13 +53,13 @@ impl Session {
|
|||
.get_async::<org::freedesktop::login1::session::Seat>(LOGIND_NAME, &session_path)
|
||||
.await;
|
||||
match seat {
|
||||
Ok(s) => s.get().0.to_string(),
|
||||
Ok(s) => s.get().1.0.to_string(),
|
||||
Err(e) => return Err(LogindError::GetSeatName(e)),
|
||||
}
|
||||
};
|
||||
Ok(Self {
|
||||
socket: socket.clone(),
|
||||
_seat: seat,
|
||||
seat,
|
||||
session_path,
|
||||
})
|
||||
}
|
||||
|
|
@ -123,4 +124,15 @@ impl Session {
|
|||
org::freedesktop::login1::session::PauseDeviceComplete { major, minor },
|
||||
);
|
||||
}
|
||||
|
||||
pub fn switch_to<F>(&self, vtnr: u32, f: F)
|
||||
where F: FnOnce(Result<&SwitchToReply, DbusError>) + 'static
|
||||
{
|
||||
self.socket.call(
|
||||
LOGIND_NAME,
|
||||
&self.seat,
|
||||
org::freedesktop::login1::seat::SwitchTo { vtnr },
|
||||
|r| f(r),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue