mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Move logind-zbus to own crate and publish
This commit is contained in:
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -506,18 +506,6 @@ dependencies = [
|
|||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "logind-zbus"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"zbus",
|
|
||||||
"zbus_macros",
|
|
||||||
"zvariant",
|
|
||||||
"zvariant_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mac-notification-sys"
|
name = "mac-notification-sys"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["asusctl", "asus-notify", "daemon", "rog-types", "rog-dbus", "logind-zbus"]
|
members = ["asusctl", "asus-notify", "daemon", "rog-types", "rog-dbus"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "logind-zbus"
|
|
||||||
version = "0.1.0"
|
|
||||||
license = "MPL-2.0"
|
|
||||||
readme = "README.md"
|
|
||||||
authors = ["Luke D Jones <luke@ljones.dev>"]
|
|
||||||
edition = "2018"
|
|
||||||
description = "A dbus client (using zbus) for logind"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
serde = "^1.0"
|
|
||||||
serde_json = "^1.0"
|
|
||||||
zbus = "^1.8"
|
|
||||||
zbus_macros = "^1.8"
|
|
||||||
zvariant = "^2.5"
|
|
||||||
zvariant_derive = "^2.5"
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
WIP
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
//! Reference https://freedesktop.org/wiki/Software/systemd/logind/
|
|
||||||
pub mod types;
|
|
||||||
pub mod proxy;
|
|
||||||
|
|
||||||
use proxy::{logind, session};
|
|
||||||
use zbus::{Connection, Result};
|
|
||||||
|
|
||||||
const DEFAULT_DEST: &str = "org.freedesktop.login1";
|
|
||||||
|
|
||||||
pub struct Logind<'a> {
|
|
||||||
connection: Connection,
|
|
||||||
logind_proxy: logind::ManagerProxy<'a>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Logind<'a> {
|
|
||||||
pub fn new() -> Result<Self> {
|
|
||||||
let connection = Connection::new_system()?;
|
|
||||||
let logind_proxy = logind::ManagerProxy::new(&connection)?;
|
|
||||||
Ok(Self {
|
|
||||||
connection,
|
|
||||||
logind_proxy,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn logind(&self) -> &logind::ManagerProxy<'a> {
|
|
||||||
&self.logind_proxy
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn session(&self,
|
|
||||||
path: &'a str) -> session::SessionProxy<'a> {
|
|
||||||
let session_proxy = session::SessionProxy::new_for(&self.connection, DEFAULT_DEST, path).unwrap();
|
|
||||||
session_proxy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::Logind;
|
|
||||||
use crate::types::session::SessionType;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn basic_test() {
|
|
||||||
let proxy = Logind::new().unwrap();
|
|
||||||
|
|
||||||
let sessions = proxy.logind().list_sessions().unwrap();
|
|
||||||
dbg!(&sessions);
|
|
||||||
|
|
||||||
let session_proxy = proxy.session(sessions[0].path());
|
|
||||||
//let res = session_proxy.seat().unwrap();
|
|
||||||
let res = session_proxy.name().unwrap();
|
|
||||||
dbg!(res);
|
|
||||||
let res = session_proxy.class().unwrap();
|
|
||||||
dbg!(res);
|
|
||||||
let res = session_proxy.type_().unwrap();
|
|
||||||
let e:SessionType = res.as_str().into();
|
|
||||||
dbg!(e);
|
|
||||||
dbg!(res);
|
|
||||||
let res = session_proxy.active().unwrap();
|
|
||||||
dbg!(res);
|
|
||||||
|
|
||||||
assert_eq!(2 + 2, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,420 +0,0 @@
|
|||||||
//! # DBus interface proxy for: `org.freedesktop.login1.Manager`
|
|
||||||
//!
|
|
||||||
//! This code was generated by `zbus-xmlgen` `1.0.0` from DBus introspection data.
|
|
||||||
//! Source: `Interface '/org/freedesktop/login1' from service 'org.freedesktop.login1' on system bus`.
|
|
||||||
//!
|
|
||||||
//! You may prefer to adapt it, instead of using it verbatim.
|
|
||||||
//!
|
|
||||||
//! More information can be found in the
|
|
||||||
//! [Writing a client proxy](https://zeenix.pages.freedesktop.org/zbus/client.html)
|
|
||||||
//! section of the zbus documentation.
|
|
||||||
//!
|
|
||||||
//! This DBus object implements
|
|
||||||
//! [standard DBus interfaces](https://dbus.freedesktop.org/doc/dbus-specification.html),
|
|
||||||
//! (`org.freedesktop.DBus.*`) for which the following zbus proxies can be used:
|
|
||||||
//!
|
|
||||||
//! * [`zbus::fdo::PeerProxy`]
|
|
||||||
//! * [`zbus::fdo::IntrospectableProxy`]
|
|
||||||
//! * [`zbus::fdo::PropertiesProxy`]
|
|
||||||
//!
|
|
||||||
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
|
||||||
//!
|
|
||||||
//! **NOTE!**
|
|
||||||
//! Commented out sections aren't required yet, and need work for deserialising
|
|
||||||
|
|
||||||
use zbus::dbus_proxy;
|
|
||||||
|
|
||||||
use crate::types::logind::{Seat, SessionInfo, User};
|
|
||||||
|
|
||||||
#[dbus_proxy(interface = "org.freedesktop.login1.Manager",
|
|
||||||
default_service = "org.freedesktop.login1",
|
|
||||||
default_path = "/org/freedesktop/login1")]
|
|
||||||
trait Manager {
|
|
||||||
/// ActivateSession method
|
|
||||||
fn activate_session(&self, session_id: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// ActivateSessionOnSeat method
|
|
||||||
fn activate_session_on_seat(&self, session_id: &str, seat_id: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// AttachDevice method
|
|
||||||
fn attach_device(&self, seat_id: &str, sysfs_path: &str, interactive: bool)
|
|
||||||
-> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// CanHalt method
|
|
||||||
fn can_halt(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanHibernate method
|
|
||||||
fn can_hibernate(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanHybridSleep method
|
|
||||||
fn can_hybrid_sleep(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanPowerOff method
|
|
||||||
fn can_power_off(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanReboot method
|
|
||||||
fn can_reboot(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanRebootParameter method
|
|
||||||
fn can_reboot_parameter(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanRebootToBootLoaderEntry method
|
|
||||||
fn can_reboot_to_boot_loader_entry(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanRebootToBootLoaderMenu method
|
|
||||||
fn can_reboot_to_boot_loader_menu(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanRebootToFirmwareSetup method
|
|
||||||
fn can_reboot_to_firmware_setup(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanSuspend method
|
|
||||||
fn can_suspend(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CanSuspendThenHibernate method
|
|
||||||
fn can_suspend_then_hibernate(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// CancelScheduledShutdown method
|
|
||||||
fn cancel_scheduled_shutdown(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
// /// CreateSession method
|
|
||||||
// fn create_session(
|
|
||||||
// &self,
|
|
||||||
// uid: u32,
|
|
||||||
// pid: u32,
|
|
||||||
// service: &str,
|
|
||||||
// r#type: &str,
|
|
||||||
// class: &str,
|
|
||||||
// desktop: &str,
|
|
||||||
// seat_id: &str,
|
|
||||||
// vtnr: u32,
|
|
||||||
// tty: &str,
|
|
||||||
// display: &str,
|
|
||||||
// remote: bool,
|
|
||||||
// remote_user: &str,
|
|
||||||
// remote_host: &str,
|
|
||||||
// properties: &[(&str, zvariant::Value)],
|
|
||||||
// ) -> zbus::Result<(
|
|
||||||
// String,
|
|
||||||
// zvariant::OwnedObjectPath,
|
|
||||||
// String,
|
|
||||||
// std::os::unix::io::RawFd,
|
|
||||||
// u32,
|
|
||||||
// String,
|
|
||||||
// u32,
|
|
||||||
// bool,
|
|
||||||
// )>;
|
|
||||||
|
|
||||||
/// FlushDevices method
|
|
||||||
fn flush_devices(&self, interactive: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// GetSeat method
|
|
||||||
fn get_seat(&self, seat_id: &str) -> zbus::Result<zvariant::OwnedObjectPath>;
|
|
||||||
|
|
||||||
/// GetSession method
|
|
||||||
fn get_session(&self, session_id: &str) -> zbus::Result<zvariant::OwnedObjectPath>;
|
|
||||||
|
|
||||||
/// GetSessionByPID method
|
|
||||||
fn get_session_by_pid(&self, pid: u32) -> zbus::Result<zvariant::OwnedObjectPath>;
|
|
||||||
|
|
||||||
/// GetUser method
|
|
||||||
fn get_user(&self, uid: u32) -> zbus::Result<zvariant::OwnedObjectPath>;
|
|
||||||
|
|
||||||
/// GetUserByPID method
|
|
||||||
fn get_user_by_pid(&self, pid: u32) -> zbus::Result<zvariant::OwnedObjectPath>;
|
|
||||||
|
|
||||||
/// Halt method
|
|
||||||
fn halt(&self, interactive: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Hibernate method
|
|
||||||
fn hibernate(&self, interactive: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// HybridSleep method
|
|
||||||
fn hybrid_sleep(&self, interactive: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Inhibit method
|
|
||||||
fn inhibit(
|
|
||||||
&self,
|
|
||||||
what: &str,
|
|
||||||
who: &str,
|
|
||||||
why: &str,
|
|
||||||
mode: &str,
|
|
||||||
) -> zbus::Result<std::os::unix::io::RawFd>;
|
|
||||||
|
|
||||||
/// KillSession method
|
|
||||||
fn kill_session(&self, session_id: &str, who: &str, signal_number: i32) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// KillUser method
|
|
||||||
fn kill_user(&self, uid: u32, signal_number: i32) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// ListInhibitors method
|
|
||||||
fn list_inhibitors(&self) -> zbus::Result<Vec<(String, String, String, String, u32, u32)>>;
|
|
||||||
|
|
||||||
/// ListSeats method
|
|
||||||
fn list_seats(&self) -> zbus::Result<Vec<Seat>>;
|
|
||||||
|
|
||||||
/// ListSessions method
|
|
||||||
fn list_sessions(
|
|
||||||
&self,
|
|
||||||
) -> zbus::Result<Vec<SessionInfo>>;
|
|
||||||
|
|
||||||
/// ListUsers method
|
|
||||||
fn list_users(&self) -> zbus::Result<Vec<User>>;
|
|
||||||
|
|
||||||
/// LockSession method
|
|
||||||
fn lock_session(&self, session_id: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// LockSessions method
|
|
||||||
fn lock_sessions(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// PowerOff method
|
|
||||||
fn power_off(&self, interactive: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Reboot method
|
|
||||||
fn reboot(&self, interactive: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// ReleaseSession method
|
|
||||||
fn release_session(&self, session_id: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// ScheduleShutdown method
|
|
||||||
fn schedule_shutdown(&self, r#type: &str, usec: u64) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetRebootParameter method
|
|
||||||
fn set_reboot_parameter(&self, parameter: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetRebootToBootLoaderEntry method
|
|
||||||
fn set_reboot_to_boot_loader_entry(&self, boot_loader_entry: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetRebootToBootLoaderMenu method
|
|
||||||
fn set_reboot_to_boot_loader_menu(&self, timeout: u64) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetRebootToFirmwareSetup method
|
|
||||||
fn set_reboot_to_firmware_setup(&self, enable: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetUserLinger method
|
|
||||||
fn set_user_linger(&self, uid: u32, enable: bool, interactive: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetWallMessage method
|
|
||||||
fn set_wall_message(&self, wall_message: &str, enable: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Suspend method
|
|
||||||
fn suspend(&self, interactive: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SuspendThenHibernate method
|
|
||||||
fn suspend_then_hibernate(&self, interactive: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// TerminateSeat method
|
|
||||||
fn terminate_seat(&self, seat_id: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// TerminateSession method
|
|
||||||
fn terminate_session(&self, session_id: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// TerminateUser method
|
|
||||||
fn terminate_user(&self, uid: u32) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// UnlockSession method
|
|
||||||
fn unlock_session(&self, session_id: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// UnlockSessions method
|
|
||||||
fn unlock_sessions(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// PrepareForShutdown signal
|
|
||||||
#[dbus_proxy(signal)]
|
|
||||||
fn prepare_for_shutdown(&self, start: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// PrepareForSleep signal
|
|
||||||
#[dbus_proxy(signal)]
|
|
||||||
fn prepare_for_sleep(&self, start: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
// /// SeatNew signal
|
|
||||||
// #[dbus_proxy(signal)]
|
|
||||||
// fn seat_new(&self, seat_id: &str, object_path: &zvariant::ObjectPath) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
// /// SeatRemoved signal
|
|
||||||
// #[dbus_proxy(signal)]
|
|
||||||
// fn seat_removed(&self, seat_id: &str, object_path: &zvariant::ObjectPath) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
// /// SessionNew signal
|
|
||||||
// #[dbus_proxy(signal)]
|
|
||||||
// fn session_new(&self, session_id: &str, object_path: &zvariant::ObjectPath)
|
|
||||||
// -> zbus::Result<()>;
|
|
||||||
|
|
||||||
// /// SessionRemoved signal
|
|
||||||
// #[dbus_proxy(signal)]
|
|
||||||
// fn session_removed(
|
|
||||||
// &self,
|
|
||||||
// session_id: &str,
|
|
||||||
// object_path: &zvariant::ObjectPath,
|
|
||||||
// ) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
// /// UserNew signal
|
|
||||||
// #[dbus_proxy(signal)]
|
|
||||||
// fn user_new(&self, uid: u32, object_path: &zvariant::ObjectPath) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
// /// UserRemoved signal
|
|
||||||
// #[dbus_proxy(signal)]
|
|
||||||
// fn user_removed(&self, uid: u32, object_path: &zvariant::ObjectPath) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// BlockInhibited property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn block_inhibited(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// BootLoaderEntries property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn boot_loader_entries(&self) -> zbus::Result<Vec<String>>;
|
|
||||||
|
|
||||||
/// DelayInhibited property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn delay_inhibited(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// Docked property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn docked(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// EnableWallMessages property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn enable_wall_messages(&self) -> zbus::Result<bool>;
|
|
||||||
#[DBusProxy(property)]
|
|
||||||
fn set_enable_wall_messages(&self, value: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// HandleHibernateKey property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn handle_hibernate_key(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// HandleLidSwitch property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn handle_lid_switch(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// HandleLidSwitchDocked property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn handle_lid_switch_docked(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// HandleLidSwitchExternalPower property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn handle_lid_switch_external_power(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// HandlePowerKey property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn handle_power_key(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// HandleSuspendKey property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn handle_suspend_key(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// HoldoffTimeoutUSec property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn holdoff_timeout_usec(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// IdleAction property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn idle_action(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// IdleActionUSec property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn idle_action_usec(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// IdleHint property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn idle_hint(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// IdleSinceHint property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn idle_since_hint(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// IdleSinceHintMonotonic property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn idle_since_hint_monotonic(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// InhibitDelayMaxUSec property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn inhibit_delay_max_usec(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// InhibitorsMax property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn inhibitors_max(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// KillExcludeUsers property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn kill_exclude_users(&self) -> zbus::Result<Vec<String>>;
|
|
||||||
|
|
||||||
/// KillOnlyUsers property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn kill_only_users(&self) -> zbus::Result<Vec<String>>;
|
|
||||||
|
|
||||||
/// KillUserProcesses property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn kill_user_processes(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// LidClosed property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn lid_closed(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// NAutoVTs property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn nauto_vts(&self) -> zbus::Result<u32>;
|
|
||||||
|
|
||||||
/// NCurrentInhibitors property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn ncurrent_inhibitors(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// NCurrentSessions property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn ncurrent_sessions(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// OnExternalPower property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn on_external_power(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// PreparingForShutdown property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn preparing_for_shutdown(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// PreparingForSleep property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn preparing_for_sleep(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// RebootParameter property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn reboot_parameter(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// RebootToBootLoaderEntry property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn reboot_to_boot_loader_entry(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// RebootToBootLoaderMenu property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn reboot_to_boot_loader_menu(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// RebootToFirmwareSetup property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn reboot_to_firmware_setup(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// RemoveIPC property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn remove_ipc(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// RuntimeDirectoryInodesMax property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn runtime_directory_inodes_max(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// RuntimeDirectorySize property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn runtime_directory_size(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
// /// ScheduledShutdown property
|
|
||||||
// #[dbus_proxy(property)]
|
|
||||||
// fn scheduled_shutdown(&self) -> zbus::Result<(String, u64)>;
|
|
||||||
|
|
||||||
/// SessionsMax property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn sessions_max(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// UserStopDelayUSec property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn user_stop_delay_usec(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// WallMessage property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn wall_message(&self) -> zbus::Result<String>;
|
|
||||||
// #[DBusProxy(property)]
|
|
||||||
// fn set_wall_message(&self, value: &str) -> zbus::Result<()>;
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
pub mod logind;
|
|
||||||
pub mod session;
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
//! # DBus interface proxy for: `org.freedesktop.login1.Session`
|
|
||||||
//!
|
|
||||||
//! This code was generated by `zbus-xmlgen` `1.0.0` from DBus introspection data.
|
|
||||||
//! Source: `Interface '/org/freedesktop/login1/session/_36' from service 'org.freedesktop.login1' on system bus`.
|
|
||||||
//!
|
|
||||||
//! You may prefer to adapt it, instead of using it verbatim.
|
|
||||||
//!
|
|
||||||
//! More information can be found in the
|
|
||||||
//! [Writing a client proxy](https://dbus.pages.freedesktop.org/zbus/client.html)
|
|
||||||
//! section of the zbus documentation.
|
|
||||||
//!
|
|
||||||
//! This DBus object implements
|
|
||||||
//! [standard DBus interfaces](https://dbus.freedesktop.org/doc/dbus-specification.html),
|
|
||||||
//! (`org.freedesktop.DBus.*`) for which the following zbus proxies can be used:
|
|
||||||
//!
|
|
||||||
//! * [`zbus::fdo::PeerProxy`]
|
|
||||||
//! * [`zbus::fdo::IntrospectableProxy`]
|
|
||||||
//! * [`zbus::fdo::PropertiesProxy`]
|
|
||||||
//!
|
|
||||||
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
|
||||||
|
|
||||||
use zbus::dbus_proxy;
|
|
||||||
|
|
||||||
#[dbus_proxy(interface = "org.freedesktop.login1.Session",
|
|
||||||
default_service = "org.freedesktop.login1",)]
|
|
||||||
trait Session {
|
|
||||||
/// Activate method
|
|
||||||
fn activate(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Kill method
|
|
||||||
fn kill(&self, who: &str, signal_number: i32) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Lock method
|
|
||||||
fn lock(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// PauseDeviceComplete method
|
|
||||||
fn pause_device_complete(&self, major: u32, minor: u32) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// ReleaseControl method
|
|
||||||
fn release_control(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// ReleaseDevice method
|
|
||||||
fn release_device(&self, major: u32, minor: u32) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetBrightness method
|
|
||||||
fn set_brightness(&self, subsystem: &str, name: &str, brightness: u32) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetIdleHint method
|
|
||||||
fn set_idle_hint(&self, idle: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetLockedHint method
|
|
||||||
fn set_locked_hint(&self, locked: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetType method
|
|
||||||
fn set_type(&self, type_: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// TakeControl method
|
|
||||||
fn take_control(&self, force: bool) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// TakeDevice method
|
|
||||||
fn take_device(&self, major: u32, minor: u32)
|
|
||||||
-> zbus::Result<(std::os::unix::io::RawFd, bool)>;
|
|
||||||
|
|
||||||
/// Terminate method
|
|
||||||
fn terminate(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Unlock method
|
|
||||||
fn unlock(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Lock signal
|
|
||||||
#[dbus_proxy(signal)]
|
|
||||||
fn lock(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// PauseDevice signal
|
|
||||||
#[dbus_proxy(signal)]
|
|
||||||
fn pause_device(&self, major: u32, minor: u32, type_: &str) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// ResumeDevice signal
|
|
||||||
#[dbus_proxy(signal)]
|
|
||||||
fn resume_device(
|
|
||||||
&self,
|
|
||||||
major: u32,
|
|
||||||
minor: u32,
|
|
||||||
fd: std::os::unix::io::RawFd,
|
|
||||||
) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Unlock signal
|
|
||||||
#[dbus_proxy(signal)]
|
|
||||||
fn unlock(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// Active property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn active(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// Audit property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn audit(&self) -> zbus::Result<u32>;
|
|
||||||
|
|
||||||
/// Class property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn class(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// Desktop property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn desktop(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// Display property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn display(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// Id property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn id(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// IdleHint property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn idle_hint(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// IdleSinceHint property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn idle_since_hint(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// IdleSinceHintMonotonic property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn idle_since_hint_monotonic(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// Leader property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn leader(&self) -> zbus::Result<u32>;
|
|
||||||
|
|
||||||
/// LockedHint property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn locked_hint(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// Name property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn name(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// Remote property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn remote(&self) -> zbus::Result<bool>;
|
|
||||||
|
|
||||||
/// RemoteHost property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn remote_host(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// RemoteUser property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn remote_user(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// Scope property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn scope(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
// /// Seat property
|
|
||||||
// #[dbus_proxy(property)]
|
|
||||||
// fn seat(&self) -> zbus::Result<Seat>;
|
|
||||||
|
|
||||||
/// Service property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn service(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// State property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn state(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// TTY property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn tty(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
/// Timestamp property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn timestamp(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// TimestampMonotonic property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn timestamp_monotonic(&self) -> zbus::Result<u64>;
|
|
||||||
|
|
||||||
/// Type property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn type_(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
// /// User property
|
|
||||||
// #[dbus_proxy(property)]
|
|
||||||
// fn user(&self) -> zbus::Result<(u32, zvariant::OwnedObjectPath)>;
|
|
||||||
|
|
||||||
/// VTNr property
|
|
||||||
#[dbus_proxy(property)]
|
|
||||||
fn vtnr(&self) -> zbus::Result<u32>;
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use zvariant_derive::Type;
|
|
||||||
use zvariant::OwnedObjectPath;
|
|
||||||
|
|
||||||
#[derive(Debug, Type, Serialize, Deserialize)]
|
|
||||||
pub struct SessionInfo {
|
|
||||||
/// Session ID
|
|
||||||
sid: String,
|
|
||||||
/// User ID
|
|
||||||
uid: u32,
|
|
||||||
/// Name of session user
|
|
||||||
user: String,
|
|
||||||
seat: String,
|
|
||||||
path: OwnedObjectPath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SessionInfo {
|
|
||||||
pub fn sid(&self) -> &str {
|
|
||||||
&self.sid
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn uid(&self) -> u32 {
|
|
||||||
self.uid
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn user(&self) -> &str {
|
|
||||||
&self.user
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn seat(&self) -> &str {
|
|
||||||
&self.seat
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &OwnedObjectPath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Type, Serialize, Deserialize)]
|
|
||||||
pub struct Seat {
|
|
||||||
id: String,
|
|
||||||
/// Name of session user
|
|
||||||
path: OwnedObjectPath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Seat {
|
|
||||||
pub fn id(&self) -> &str {
|
|
||||||
&self.id
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &OwnedObjectPath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Type, Serialize, Deserialize)]
|
|
||||||
pub struct User {
|
|
||||||
uid: u32,
|
|
||||||
name: String,
|
|
||||||
/// Name of session user
|
|
||||||
path: OwnedObjectPath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl User {
|
|
||||||
pub fn uid(&self) -> u32 {
|
|
||||||
self.uid
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn name(&self) -> &str {
|
|
||||||
&self.name
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &OwnedObjectPath {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
pub mod logind;
|
|
||||||
pub mod session;
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#[derive(Debug, PartialEq)]
|
|
||||||
pub enum SessionType {
|
|
||||||
X11,
|
|
||||||
Wayland,
|
|
||||||
TTY,
|
|
||||||
Other(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<String> for SessionType {
|
|
||||||
fn from(s: String) -> Self {
|
|
||||||
<SessionType>::from(s.as_str())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&str> for SessionType {
|
|
||||||
fn from(s: &str) -> Self {
|
|
||||||
match s {
|
|
||||||
"wayland" => SessionType::Wayland,
|
|
||||||
"x11" => SessionType::X11,
|
|
||||||
"tty" => SessionType::TTY,
|
|
||||||
_ => SessionType::Other(s.to_owned()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user