From 842fa48fac3e2366a035075f79154260d22636b2 Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Fri, 12 Mar 2021 15:04:37 +1300 Subject: [PATCH 1/6] Refresh sessions list every 3rd active check --- daemon/src/ctrl_gfx/gfx.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/daemon/src/ctrl_gfx/gfx.rs b/daemon/src/ctrl_gfx/gfx.rs index d882669a..b463795d 100644 --- a/daemon/src/ctrl_gfx/gfx.rs +++ b/daemon/src/ctrl_gfx/gfx.rs @@ -421,18 +421,29 @@ impl CtrlGraphics { vendor: GfxVendors, devices: Vec, bus: PciBus, - sessions: Vec, killer: mpsc::Receiver, ) -> Result { info!("GFX: display-manager thread started"); + let mut sessions: Vec = get_sessions().unwrap(); + + const SLEEP_PERIOD: Duration = Duration::from_millis(300); + const REFRESH_COUNTDOWN: u32 = 3; + let mut refresh_sessions = REFRESH_COUNTDOWN; while are_gfx_sessions_alive(&sessions) { if let Ok(stop) = killer.try_recv() { if stop { return Ok("Graphics mode change was cancelled".into()); } } - sleep(Duration::from_millis(300)); + // Don't spin at max speed + sleep(SLEEP_PERIOD); + if refresh_sessions == 0 { + refresh_sessions = REFRESH_COUNTDOWN; + sessions = get_sessions().unwrap(); + } + refresh_sessions -= 1; } + info!("GFX: all graphical user sessions ended, continuing"); Self::do_display_manager_action("stop")?; @@ -485,7 +496,6 @@ impl CtrlGraphics { let devices = self.nvidia.clone(); let bus = self.bus.clone(); - let sessions = get_sessions().unwrap(); let (tx, rx) = mpsc::channel(); if let Ok(mut lock) = self.thread_kill.lock() { *lock = Some(tx); @@ -496,7 +506,7 @@ impl CtrlGraphics { Self::save_gfx_mode(vendor, self.config.clone())?; let _join: JoinHandle<()> = std::thread::spawn(move || { - Self::fire_starter(vendor, devices, bus, sessions, rx) + Self::fire_starter(vendor, devices, bus, rx) .map_err(|err| { error!("GFX: {}", err); }) From 875ff6d3543522856a4f4634f50673aaf370e8bb Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Fri, 12 Mar 2021 16:55:52 +1300 Subject: [PATCH 2/6] Begin implementing logind dbus crate --- logind-zbus/Cargo.toml | 13 + logind-zbus/src/lib.rs | 19 ++ logind-zbus/src/zbus_logind.rs | 418 +++++++++++++++++++++++++++++++++ 3 files changed, 450 insertions(+) create mode 100644 logind-zbus/Cargo.toml create mode 100644 logind-zbus/src/lib.rs create mode 100644 logind-zbus/src/zbus_logind.rs diff --git a/logind-zbus/Cargo.toml b/logind-zbus/Cargo.toml new file mode 100644 index 00000000..e9d36ca2 --- /dev/null +++ b/logind-zbus/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "logind-zbus" +version = "0.1.0" +authors = ["Luke D Jones "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde_json = "^1.0" +zbus = "^1.8" +zbus_macros = "^1.8" +zvariant = "^2.4" \ No newline at end of file diff --git a/logind-zbus/src/lib.rs b/logind-zbus/src/lib.rs new file mode 100644 index 00000000..d8804076 --- /dev/null +++ b/logind-zbus/src/lib.rs @@ -0,0 +1,19 @@ +mod zbus_logind; + +#[cfg(test)] +mod tests { + use zbus::Connection; + + use crate::zbus_logind; + + #[test] + fn it_works() { + let conn = Connection::new_system().unwrap(); + let proxy = zbus_logind::ManagerProxy::new(&conn).unwrap(); + + let sessions = proxy.list_sessions().unwrap(); + dbg!(sessions); + + assert_eq!(2 + 2, 4); + } +} diff --git a/logind-zbus/src/zbus_logind.rs b/logind-zbus/src/zbus_logind.rs new file mode 100644 index 00000000..28c53da1 --- /dev/null +++ b/logind-zbus/src/zbus_logind.rs @@ -0,0 +1,418 @@ +//! # 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; + +#[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; + + /// CanHibernate method + fn can_hibernate(&self) -> zbus::Result; + + /// CanHybridSleep method + fn can_hybrid_sleep(&self) -> zbus::Result; + + /// CanPowerOff method + fn can_power_off(&self) -> zbus::Result; + + /// CanReboot method + fn can_reboot(&self) -> zbus::Result; + + /// CanRebootParameter method + fn can_reboot_parameter(&self) -> zbus::Result; + + /// CanRebootToBootLoaderEntry method + fn can_reboot_to_boot_loader_entry(&self) -> zbus::Result; + + /// CanRebootToBootLoaderMenu method + fn can_reboot_to_boot_loader_menu(&self) -> zbus::Result; + + /// CanRebootToFirmwareSetup method + fn can_reboot_to_firmware_setup(&self) -> zbus::Result; + + /// CanSuspend method + fn can_suspend(&self) -> zbus::Result; + + /// CanSuspendThenHibernate method + fn can_suspend_then_hibernate(&self) -> zbus::Result; + + /// CancelScheduledShutdown method + fn cancel_scheduled_shutdown(&self) -> zbus::Result; + + // /// 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; + + /// GetSession method + fn get_session(&self, session_id: &str) -> zbus::Result; + + /// GetSessionByPID method + fn get_session_by_pid(&self, pid: u32) -> zbus::Result; + + /// GetUser method + fn get_user(&self, uid: u32) -> zbus::Result; + + /// GetUserByPID method + fn get_user_by_pid(&self, pid: u32) -> zbus::Result; + + /// 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; + + /// 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>; + + /// ListSeats method + fn list_seats(&self) -> zbus::Result>; + + /// ListSessions method + fn list_sessions( + &self, + ) -> zbus::Result>; + + /// ListUsers method + fn list_users(&self) -> zbus::Result>; + + /// 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; + + /// BootLoaderEntries property + #[dbus_proxy(property)] + fn boot_loader_entries(&self) -> zbus::Result>; + + /// DelayInhibited property + #[dbus_proxy(property)] + fn delay_inhibited(&self) -> zbus::Result; + + /// Docked property + #[dbus_proxy(property)] + fn docked(&self) -> zbus::Result; + + /// EnableWallMessages property + #[dbus_proxy(property)] + fn enable_wall_messages(&self) -> zbus::Result; + #[DBusProxy(property)] + fn set_enable_wall_messages(&self, value: bool) -> zbus::Result<()>; + + /// HandleHibernateKey property + #[dbus_proxy(property)] + fn handle_hibernate_key(&self) -> zbus::Result; + + /// HandleLidSwitch property + #[dbus_proxy(property)] + fn handle_lid_switch(&self) -> zbus::Result; + + /// HandleLidSwitchDocked property + #[dbus_proxy(property)] + fn handle_lid_switch_docked(&self) -> zbus::Result; + + /// HandleLidSwitchExternalPower property + #[dbus_proxy(property)] + fn handle_lid_switch_external_power(&self) -> zbus::Result; + + /// HandlePowerKey property + #[dbus_proxy(property)] + fn handle_power_key(&self) -> zbus::Result; + + /// HandleSuspendKey property + #[dbus_proxy(property)] + fn handle_suspend_key(&self) -> zbus::Result; + + /// HoldoffTimeoutUSec property + #[dbus_proxy(property)] + fn holdoff_timeout_usec(&self) -> zbus::Result; + + /// IdleAction property + #[dbus_proxy(property)] + fn idle_action(&self) -> zbus::Result; + + /// IdleActionUSec property + #[dbus_proxy(property)] + fn idle_action_usec(&self) -> zbus::Result; + + /// IdleHint property + #[dbus_proxy(property)] + fn idle_hint(&self) -> zbus::Result; + + /// IdleSinceHint property + #[dbus_proxy(property)] + fn idle_since_hint(&self) -> zbus::Result; + + /// IdleSinceHintMonotonic property + #[dbus_proxy(property)] + fn idle_since_hint_monotonic(&self) -> zbus::Result; + + /// InhibitDelayMaxUSec property + #[dbus_proxy(property)] + fn inhibit_delay_max_usec(&self) -> zbus::Result; + + /// InhibitorsMax property + #[dbus_proxy(property)] + fn inhibitors_max(&self) -> zbus::Result; + + /// KillExcludeUsers property + #[dbus_proxy(property)] + fn kill_exclude_users(&self) -> zbus::Result>; + + /// KillOnlyUsers property + #[dbus_proxy(property)] + fn kill_only_users(&self) -> zbus::Result>; + + /// KillUserProcesses property + #[dbus_proxy(property)] + fn kill_user_processes(&self) -> zbus::Result; + + /// LidClosed property + #[dbus_proxy(property)] + fn lid_closed(&self) -> zbus::Result; + + /// NAutoVTs property + #[dbus_proxy(property)] + fn nauto_vts(&self) -> zbus::Result; + + /// NCurrentInhibitors property + #[dbus_proxy(property)] + fn ncurrent_inhibitors(&self) -> zbus::Result; + + /// NCurrentSessions property + #[dbus_proxy(property)] + fn ncurrent_sessions(&self) -> zbus::Result; + + /// OnExternalPower property + #[dbus_proxy(property)] + fn on_external_power(&self) -> zbus::Result; + + /// PreparingForShutdown property + #[dbus_proxy(property)] + fn preparing_for_shutdown(&self) -> zbus::Result; + + /// PreparingForSleep property + #[dbus_proxy(property)] + fn preparing_for_sleep(&self) -> zbus::Result; + + /// RebootParameter property + #[dbus_proxy(property)] + fn reboot_parameter(&self) -> zbus::Result; + + /// RebootToBootLoaderEntry property + #[dbus_proxy(property)] + fn reboot_to_boot_loader_entry(&self) -> zbus::Result; + + /// RebootToBootLoaderMenu property + #[dbus_proxy(property)] + fn reboot_to_boot_loader_menu(&self) -> zbus::Result; + + /// RebootToFirmwareSetup property + #[dbus_proxy(property)] + fn reboot_to_firmware_setup(&self) -> zbus::Result; + + /// RemoveIPC property + #[dbus_proxy(property)] + fn remove_ipc(&self) -> zbus::Result; + + /// RuntimeDirectoryInodesMax property + #[dbus_proxy(property)] + fn runtime_directory_inodes_max(&self) -> zbus::Result; + + /// RuntimeDirectorySize property + #[dbus_proxy(property)] + fn runtime_directory_size(&self) -> zbus::Result; + + // /// ScheduledShutdown property + // #[dbus_proxy(property)] + // fn scheduled_shutdown(&self) -> zbus::Result<(String, u64)>; + + /// SessionsMax property + #[dbus_proxy(property)] + fn sessions_max(&self) -> zbus::Result; + + /// UserStopDelayUSec property + #[dbus_proxy(property)] + fn user_stop_delay_usec(&self) -> zbus::Result; + + /// WallMessage property + #[dbus_proxy(property)] + fn wall_message(&self) -> zbus::Result; + // #[DBusProxy(property)] + // fn set_wall_message(&self, value: &str) -> zbus::Result<()>; +} From ae4f7f9949eb58506fe3f3bbccfafd5b79703d2a Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Fri, 12 Mar 2021 22:00:31 +1300 Subject: [PATCH 3/6] Buildup of logind dbus methods --- Cargo.lock | 12 ++ Cargo.toml | 2 +- daemon/src/ctrl_gfx/gfx.rs | 21 +- daemon/src/error.rs | 6 + logind-zbus/Cargo.toml | 4 +- logind-zbus/src/lib.rs | 62 +++++- .../src/{zbus_logind.rs => proxy/logind.rs} | 8 +- logind-zbus/src/proxy/mod.rs | 2 + logind-zbus/src/proxy/session.rs | 190 ++++++++++++++++++ logind-zbus/src/types/logind.rs | 77 +++++++ logind-zbus/src/types/mod.rs | 2 + logind-zbus/src/types/session.rs | 24 +++ 12 files changed, 391 insertions(+), 19 deletions(-) rename logind-zbus/src/{zbus_logind.rs => proxy/logind.rs} (98%) create mode 100644 logind-zbus/src/proxy/mod.rs create mode 100644 logind-zbus/src/proxy/session.rs create mode 100644 logind-zbus/src/types/logind.rs create mode 100644 logind-zbus/src/types/mod.rs create mode 100644 logind-zbus/src/types/session.rs diff --git a/Cargo.lock b/Cargo.lock index c2cbb444..63b4f12e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -523,6 +523,18 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "logind-zbus" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "zbus", + "zbus_macros", + "zvariant", + "zvariant_derive", +] + [[package]] name = "loom" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 9462e627..fd5f05aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["asusctl", "asus-notify", "daemon", "rog-types", "rog-dbus"] +members = ["asusctl", "asus-notify", "daemon", "rog-types", "rog-dbus", "logind-zbus"] [profile.release] lto = true diff --git a/daemon/src/ctrl_gfx/gfx.rs b/daemon/src/ctrl_gfx/gfx.rs index b463795d..9340f6cb 100644 --- a/daemon/src/ctrl_gfx/gfx.rs +++ b/daemon/src/ctrl_gfx/gfx.rs @@ -382,6 +382,15 @@ impl CtrlGraphics { return Err(GfxError::DisplayManagerTimeout(state.into()).into()); } + /// Write the config changes and add/remove drivers and devices depending + /// on selected mode: + /// + /// Tasks: + /// - write xorg config + /// - write modprobe config + /// - rescan for devices + /// + add drivers + /// + or remove drivers and devices pub fn do_vendor_tasks( vendor: GfxVendors, devices: &[GraphicsDevice], @@ -416,7 +425,7 @@ impl CtrlGraphics { Ok(()) } - /// Spools until all user sessions are ended + /// Spools until all user sessions are ended then switches to requested mode fn fire_starter( vendor: GfxVendors, devices: Vec, @@ -424,7 +433,7 @@ impl CtrlGraphics { killer: mpsc::Receiver, ) -> Result { info!("GFX: display-manager thread started"); - let mut sessions: Vec = get_sessions().unwrap(); + let mut sessions: Vec = get_sessions()?; const SLEEP_PERIOD: Duration = Duration::from_millis(300); const REFRESH_COUNTDOWN: u32 = 3; @@ -439,7 +448,7 @@ impl CtrlGraphics { sleep(SLEEP_PERIOD); if refresh_sessions == 0 { refresh_sessions = REFRESH_COUNTDOWN; - sessions = get_sessions().unwrap(); + sessions = get_sessions()?; } refresh_sessions -= 1; } @@ -472,9 +481,11 @@ impl CtrlGraphics { Ok(format!("Graphics mode changed to {} successfully", v)) } - /// For manually calling (not on boot/startup) + /// Initiates a mode change by starting a thread that will wait until all + /// graphical sessions are exited before performing the tasks required + /// to switch modes. /// - /// Will stop and start display manager without warning + /// For manually calling (not on boot/startup) via dbus pub fn set_gfx_config(&mut self, vendor: GfxVendors) -> Result { if let Ok(gsync) = CtrlRogBios::get_gfx_mode() { if gsync == 1 { diff --git a/daemon/src/error.rs b/daemon/src/error.rs index f4635847..e2f71e08 100644 --- a/daemon/src/error.rs +++ b/daemon/src/error.rs @@ -81,3 +81,9 @@ impl From for RogError { } } } + +impl From for RogError { + fn from(err: SessionError) -> Self { + RogError::Session(err) + } +} \ No newline at end of file diff --git a/logind-zbus/Cargo.toml b/logind-zbus/Cargo.toml index e9d36ca2..d662f5c0 100644 --- a/logind-zbus/Cargo.toml +++ b/logind-zbus/Cargo.toml @@ -7,7 +7,9 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +serde = "^1.0" serde_json = "^1.0" zbus = "^1.8" zbus_macros = "^1.8" -zvariant = "^2.4" \ No newline at end of file +zvariant = "^2.5" +zvariant_derive = "^2.5" \ No newline at end of file diff --git a/logind-zbus/src/lib.rs b/logind-zbus/src/lib.rs index d8804076..d4a62751 100644 --- a/logind-zbus/src/lib.rs +++ b/logind-zbus/src/lib.rs @@ -1,19 +1,63 @@ -mod zbus_logind; +//! 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 { + 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 zbus::Connection; - - use crate::zbus_logind; + use crate::Logind; + use crate::types::session::SessionType; #[test] - fn it_works() { - let conn = Connection::new_system().unwrap(); - let proxy = zbus_logind::ManagerProxy::new(&conn).unwrap(); + fn basic_test() { + let proxy = Logind::new().unwrap(); - let sessions = proxy.list_sessions().unwrap(); - dbg!(sessions); + 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); } } diff --git a/logind-zbus/src/zbus_logind.rs b/logind-zbus/src/proxy/logind.rs similarity index 98% rename from logind-zbus/src/zbus_logind.rs rename to logind-zbus/src/proxy/logind.rs index 28c53da1..f34bac0c 100644 --- a/logind-zbus/src/zbus_logind.rs +++ b/logind-zbus/src/proxy/logind.rs @@ -24,6 +24,8 @@ 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")] @@ -148,15 +150,15 @@ trait Manager { fn list_inhibitors(&self) -> zbus::Result>; /// ListSeats method - fn list_seats(&self) -> zbus::Result>; + fn list_seats(&self) -> zbus::Result>; /// ListSessions method fn list_sessions( &self, - ) -> zbus::Result>; + ) -> zbus::Result>; /// ListUsers method - fn list_users(&self) -> zbus::Result>; + fn list_users(&self) -> zbus::Result>; /// LockSession method fn lock_session(&self, session_id: &str) -> zbus::Result<()>; diff --git a/logind-zbus/src/proxy/mod.rs b/logind-zbus/src/proxy/mod.rs new file mode 100644 index 00000000..fb1b4de3 --- /dev/null +++ b/logind-zbus/src/proxy/mod.rs @@ -0,0 +1,2 @@ +pub mod logind; +pub mod session; \ No newline at end of file diff --git a/logind-zbus/src/proxy/session.rs b/logind-zbus/src/proxy/session.rs new file mode 100644 index 00000000..b01137cf --- /dev/null +++ b/logind-zbus/src/proxy/session.rs @@ -0,0 +1,190 @@ +//! # 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; + + /// Audit property + #[dbus_proxy(property)] + fn audit(&self) -> zbus::Result; + + /// Class property + #[dbus_proxy(property)] + fn class(&self) -> zbus::Result; + + /// Desktop property + #[dbus_proxy(property)] + fn desktop(&self) -> zbus::Result; + + /// Display property + #[dbus_proxy(property)] + fn display(&self) -> zbus::Result; + + /// Id property + #[dbus_proxy(property)] + fn id(&self) -> zbus::Result; + + /// IdleHint property + #[dbus_proxy(property)] + fn idle_hint(&self) -> zbus::Result; + + /// IdleSinceHint property + #[dbus_proxy(property)] + fn idle_since_hint(&self) -> zbus::Result; + + /// IdleSinceHintMonotonic property + #[dbus_proxy(property)] + fn idle_since_hint_monotonic(&self) -> zbus::Result; + + /// Leader property + #[dbus_proxy(property)] + fn leader(&self) -> zbus::Result; + + /// LockedHint property + #[dbus_proxy(property)] + fn locked_hint(&self) -> zbus::Result; + + /// Name property + #[dbus_proxy(property)] + fn name(&self) -> zbus::Result; + + /// Remote property + #[dbus_proxy(property)] + fn remote(&self) -> zbus::Result; + + /// RemoteHost property + #[dbus_proxy(property)] + fn remote_host(&self) -> zbus::Result; + + /// RemoteUser property + #[dbus_proxy(property)] + fn remote_user(&self) -> zbus::Result; + + /// Scope property + #[dbus_proxy(property)] + fn scope(&self) -> zbus::Result; + + // /// Seat property + // #[dbus_proxy(property)] + // fn seat(&self) -> zbus::Result; + + /// Service property + #[dbus_proxy(property)] + fn service(&self) -> zbus::Result; + + /// State property + #[dbus_proxy(property)] + fn state(&self) -> zbus::Result; + + /// TTY property + #[dbus_proxy(property)] + fn tty(&self) -> zbus::Result; + + /// Timestamp property + #[dbus_proxy(property)] + fn timestamp(&self) -> zbus::Result; + + /// TimestampMonotonic property + #[dbus_proxy(property)] + fn timestamp_monotonic(&self) -> zbus::Result; + + /// Type property + #[dbus_proxy(property)] + fn type_(&self) -> zbus::Result; + + // /// User property + // #[dbus_proxy(property)] + // fn user(&self) -> zbus::Result<(u32, zvariant::OwnedObjectPath)>; + + /// VTNr property + #[dbus_proxy(property)] + fn vtnr(&self) -> zbus::Result; +} diff --git a/logind-zbus/src/types/logind.rs b/logind-zbus/src/types/logind.rs new file mode 100644 index 00000000..773df6fe --- /dev/null +++ b/logind-zbus/src/types/logind.rs @@ -0,0 +1,77 @@ +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 + } +} \ No newline at end of file diff --git a/logind-zbus/src/types/mod.rs b/logind-zbus/src/types/mod.rs new file mode 100644 index 00000000..064cd81a --- /dev/null +++ b/logind-zbus/src/types/mod.rs @@ -0,0 +1,2 @@ +pub mod logind; +pub mod session; diff --git a/logind-zbus/src/types/session.rs b/logind-zbus/src/types/session.rs new file mode 100644 index 00000000..3a6f5876 --- /dev/null +++ b/logind-zbus/src/types/session.rs @@ -0,0 +1,24 @@ +#[derive(Debug, PartialEq)] +pub enum SessionType { + X11, + Wayland, + TTY, + Other(String), +} + +impl From for SessionType { + fn from(s: String) -> Self { + ::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()), + } + } +} \ No newline at end of file From 82bb03233685ee5245c7866afd0bab6d59973bd6 Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Fri, 12 Mar 2021 22:02:54 +1300 Subject: [PATCH 4/6] Bump crate deps --- Cargo.lock | 150 +++++++++++++++-------------------------- daemon/Cargo.toml | 2 +- logind-zbus/Cargo.toml | 5 +- logind-zbus/README.md | 1 + rog-dbus/Cargo.toml | 2 +- 5 files changed, 62 insertions(+), 98 deletions(-) create mode 100644 logind-zbus/README.md diff --git a/Cargo.lock b/Cargo.lock index 63b4f12e..5152989c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -118,9 +118,9 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cache-padded" @@ -176,14 +176,13 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "crossbeam-utils" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae8f328835f8f5a6ceb6a7842a7f2d0c03692adb5c889347235d59194731fe3" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" dependencies = [ "autocfg", "cfg-if 1.0.0", "lazy_static", - "loom", ] [[package]] @@ -215,7 +214,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", ] [[package]] @@ -247,7 +246,7 @@ checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", ] [[package]] @@ -273,7 +272,7 @@ dependencies = [ "proc-macro2", "quote 1.0.9", "rustversion", - "syn 1.0.60", + "syn 1.0.63", "synstructure", ] @@ -288,9 +287,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" +checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" dependencies = [ "futures-channel", "futures-core", @@ -303,9 +302,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" +checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" dependencies = [ "futures-core", "futures-sink", @@ -313,15 +312,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" +checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" [[package]] name = "futures-executor" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" +checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1" dependencies = [ "futures-core", "futures-task", @@ -330,9 +329,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" +checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" [[package]] name = "futures-lite" @@ -351,36 +350,33 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" +checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7" dependencies = [ "proc-macro-hack", "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", ] [[package]] name = "futures-sink" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" +checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3" [[package]] name = "futures-task" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" -dependencies = [ - "once_cell", -] +checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" [[package]] name = "futures-util" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" +checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" dependencies = [ "futures-channel", "futures-core", @@ -396,19 +392,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generator" -version = "0.6.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9fed24fd1e18827652b4d55652899a1e9da8e54d91624dc3437a5bc3a9f9a9c" -dependencies = [ - "cc", - "libc", - "log", - "rustversion", - "winapi", -] - [[package]] name = "getrandom" version = "0.1.16" @@ -437,7 +420,7 @@ checksum = "915ef07c710d84733522461de2a734d4d62a3fd39a4d4f404c2f385ef8618d05" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", ] [[package]] @@ -488,9 +471,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" +checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" [[package]] name = "libudev-sys" @@ -535,17 +518,6 @@ dependencies = [ "zvariant_derive", ] -[[package]] -name = "loom" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d44c73b4636e497b4917eb21c33539efa3816741a2d3ff26c6316f1b529481a4" -dependencies = [ - "cfg-if 1.0.0", - "generator", - "scoped-tls", -] - [[package]] name = "mac-notification-sys" version = "0.3.0" @@ -608,9 +580,9 @@ dependencies = [ [[package]] name = "notify-rust" -version = "4.2.2" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a3a5dd7b4b415b112ce0fae1988f3e6dee90a96918bf3950b5f2289b19a04b" +checksum = "00c16afe17474a42a59062f3409a63160c63d41985b25e9e613400685b839cb6" dependencies = [ "mac-notification-sys", "serde", @@ -676,9 +648,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.5.2" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "parking" @@ -688,9 +660,9 @@ checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] name = "pin-project-lite" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" [[package]] name = "pin-utils" @@ -735,7 +707,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", "version_check", ] @@ -805,21 +777,20 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.3" +version = "1.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +checksum = "54fd1046a3107eb58f42de31d656fee6853e5d276c455fd943742dce89fc3dd3" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "rog_dbus" @@ -835,9 +806,9 @@ dependencies = [ [[package]] name = "rog_fan_curve" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71cfe91a717104796aeefea4e98ce5cefb11f2bb5dd10bba865dd4ae86273cb" +checksum = "d083149d6e2681d05882e7ff557dec07211a6349f6de9446073b2c7dfd81e2f2" dependencies = [ "serde", ] @@ -896,29 +867,29 @@ checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" [[package]] name = "serde" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" +checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", ] [[package]] name = "serde_json" -version = "1.0.62" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -933,7 +904,7 @@ checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", ] [[package]] @@ -950,7 +921,7 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", ] [[package]] @@ -993,9 +964,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.60" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +checksum = "8fd9bc7ccc2688b3344c2f48b9b546648b25ce0b20fc717ee7fa7981a8ca9717" dependencies = [ "proc-macro2", "quote 1.0.9", @@ -1019,7 +990,7 @@ checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", "unicode-xid 0.2.1", ] @@ -1041,15 +1012,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "thread_local" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" -dependencies = [ - "once_cell", -] - [[package]] name = "time" version = "0.1.44" @@ -1256,7 +1218,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", ] [[package]] @@ -1280,5 +1242,5 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote 1.0.9", - "syn 1.0.60", + "syn 1.0.63", ] diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index 33635af2..3a2425a1 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -28,7 +28,7 @@ log = "^0.4" env_logger = "^0.8" zbus = "^1.8" -zvariant = "^2.4" +zvariant = "^2.5" # serialisation serde = "^1.0" diff --git a/logind-zbus/Cargo.toml b/logind-zbus/Cargo.toml index d662f5c0..cd42d75e 100644 --- a/logind-zbus/Cargo.toml +++ b/logind-zbus/Cargo.toml @@ -1,10 +1,11 @@ [package] name = "logind-zbus" version = "0.1.0" +license = "MPL-2.0" +readme = "README.md" authors = ["Luke D Jones "] edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +description = "A dbus client (using zbus) for logind" [dependencies] serde = "^1.0" diff --git a/logind-zbus/README.md b/logind-zbus/README.md new file mode 100644 index 00000000..6d3f6659 --- /dev/null +++ b/logind-zbus/README.md @@ -0,0 +1 @@ +WIP \ No newline at end of file diff --git a/rog-dbus/Cargo.toml b/rog-dbus/Cargo.toml index f87f64e2..f99a7782 100644 --- a/rog-dbus/Cargo.toml +++ b/rog-dbus/Cargo.toml @@ -15,4 +15,4 @@ rog_types = { path = "../rog-types" } rog_fan_curve = { version = "^0.1", features = ["serde"] } zbus = "^1.8" zbus_macros = "^1.8" -zvariant = "^2.4" +zvariant = "^2.5" From 35438e2e77e42a1c0957e98bc7a9759941aacca8 Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Sat, 13 Mar 2021 22:07:31 +1300 Subject: [PATCH 5/6] Move logind-zbus to own crate and publish --- Cargo.lock | 12 - Cargo.toml | 2 +- logind-zbus/Cargo.toml | 16 -- logind-zbus/README.md | 1 - logind-zbus/src/lib.rs | 63 ----- logind-zbus/src/proxy/logind.rs | 420 ------------------------------- logind-zbus/src/proxy/mod.rs | 2 - logind-zbus/src/proxy/session.rs | 190 -------------- logind-zbus/src/types/logind.rs | 77 ------ logind-zbus/src/types/mod.rs | 2 - logind-zbus/src/types/session.rs | 24 -- 11 files changed, 1 insertion(+), 808 deletions(-) delete mode 100644 logind-zbus/Cargo.toml delete mode 100644 logind-zbus/README.md delete mode 100644 logind-zbus/src/lib.rs delete mode 100644 logind-zbus/src/proxy/logind.rs delete mode 100644 logind-zbus/src/proxy/mod.rs delete mode 100644 logind-zbus/src/proxy/session.rs delete mode 100644 logind-zbus/src/types/logind.rs delete mode 100644 logind-zbus/src/types/mod.rs delete mode 100644 logind-zbus/src/types/session.rs diff --git a/Cargo.lock b/Cargo.lock index 5152989c..233af7a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -506,18 +506,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "logind-zbus" -version = "0.1.0" -dependencies = [ - "serde", - "serde_json", - "zbus", - "zbus_macros", - "zvariant", - "zvariant_derive", -] - [[package]] name = "mac-notification-sys" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index fd5f05aa..9462e627 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["asusctl", "asus-notify", "daemon", "rog-types", "rog-dbus", "logind-zbus"] +members = ["asusctl", "asus-notify", "daemon", "rog-types", "rog-dbus"] [profile.release] lto = true diff --git a/logind-zbus/Cargo.toml b/logind-zbus/Cargo.toml deleted file mode 100644 index cd42d75e..00000000 --- a/logind-zbus/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "logind-zbus" -version = "0.1.0" -license = "MPL-2.0" -readme = "README.md" -authors = ["Luke D Jones "] -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" \ No newline at end of file diff --git a/logind-zbus/README.md b/logind-zbus/README.md deleted file mode 100644 index 6d3f6659..00000000 --- a/logind-zbus/README.md +++ /dev/null @@ -1 +0,0 @@ -WIP \ No newline at end of file diff --git a/logind-zbus/src/lib.rs b/logind-zbus/src/lib.rs deleted file mode 100644 index d4a62751..00000000 --- a/logind-zbus/src/lib.rs +++ /dev/null @@ -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 { - 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); - } -} diff --git a/logind-zbus/src/proxy/logind.rs b/logind-zbus/src/proxy/logind.rs deleted file mode 100644 index f34bac0c..00000000 --- a/logind-zbus/src/proxy/logind.rs +++ /dev/null @@ -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; - - /// CanHibernate method - fn can_hibernate(&self) -> zbus::Result; - - /// CanHybridSleep method - fn can_hybrid_sleep(&self) -> zbus::Result; - - /// CanPowerOff method - fn can_power_off(&self) -> zbus::Result; - - /// CanReboot method - fn can_reboot(&self) -> zbus::Result; - - /// CanRebootParameter method - fn can_reboot_parameter(&self) -> zbus::Result; - - /// CanRebootToBootLoaderEntry method - fn can_reboot_to_boot_loader_entry(&self) -> zbus::Result; - - /// CanRebootToBootLoaderMenu method - fn can_reboot_to_boot_loader_menu(&self) -> zbus::Result; - - /// CanRebootToFirmwareSetup method - fn can_reboot_to_firmware_setup(&self) -> zbus::Result; - - /// CanSuspend method - fn can_suspend(&self) -> zbus::Result; - - /// CanSuspendThenHibernate method - fn can_suspend_then_hibernate(&self) -> zbus::Result; - - /// CancelScheduledShutdown method - fn cancel_scheduled_shutdown(&self) -> zbus::Result; - - // /// 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; - - /// GetSession method - fn get_session(&self, session_id: &str) -> zbus::Result; - - /// GetSessionByPID method - fn get_session_by_pid(&self, pid: u32) -> zbus::Result; - - /// GetUser method - fn get_user(&self, uid: u32) -> zbus::Result; - - /// GetUserByPID method - fn get_user_by_pid(&self, pid: u32) -> zbus::Result; - - /// 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; - - /// 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>; - - /// ListSeats method - fn list_seats(&self) -> zbus::Result>; - - /// ListSessions method - fn list_sessions( - &self, - ) -> zbus::Result>; - - /// ListUsers method - fn list_users(&self) -> zbus::Result>; - - /// 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; - - /// BootLoaderEntries property - #[dbus_proxy(property)] - fn boot_loader_entries(&self) -> zbus::Result>; - - /// DelayInhibited property - #[dbus_proxy(property)] - fn delay_inhibited(&self) -> zbus::Result; - - /// Docked property - #[dbus_proxy(property)] - fn docked(&self) -> zbus::Result; - - /// EnableWallMessages property - #[dbus_proxy(property)] - fn enable_wall_messages(&self) -> zbus::Result; - #[DBusProxy(property)] - fn set_enable_wall_messages(&self, value: bool) -> zbus::Result<()>; - - /// HandleHibernateKey property - #[dbus_proxy(property)] - fn handle_hibernate_key(&self) -> zbus::Result; - - /// HandleLidSwitch property - #[dbus_proxy(property)] - fn handle_lid_switch(&self) -> zbus::Result; - - /// HandleLidSwitchDocked property - #[dbus_proxy(property)] - fn handle_lid_switch_docked(&self) -> zbus::Result; - - /// HandleLidSwitchExternalPower property - #[dbus_proxy(property)] - fn handle_lid_switch_external_power(&self) -> zbus::Result; - - /// HandlePowerKey property - #[dbus_proxy(property)] - fn handle_power_key(&self) -> zbus::Result; - - /// HandleSuspendKey property - #[dbus_proxy(property)] - fn handle_suspend_key(&self) -> zbus::Result; - - /// HoldoffTimeoutUSec property - #[dbus_proxy(property)] - fn holdoff_timeout_usec(&self) -> zbus::Result; - - /// IdleAction property - #[dbus_proxy(property)] - fn idle_action(&self) -> zbus::Result; - - /// IdleActionUSec property - #[dbus_proxy(property)] - fn idle_action_usec(&self) -> zbus::Result; - - /// IdleHint property - #[dbus_proxy(property)] - fn idle_hint(&self) -> zbus::Result; - - /// IdleSinceHint property - #[dbus_proxy(property)] - fn idle_since_hint(&self) -> zbus::Result; - - /// IdleSinceHintMonotonic property - #[dbus_proxy(property)] - fn idle_since_hint_monotonic(&self) -> zbus::Result; - - /// InhibitDelayMaxUSec property - #[dbus_proxy(property)] - fn inhibit_delay_max_usec(&self) -> zbus::Result; - - /// InhibitorsMax property - #[dbus_proxy(property)] - fn inhibitors_max(&self) -> zbus::Result; - - /// KillExcludeUsers property - #[dbus_proxy(property)] - fn kill_exclude_users(&self) -> zbus::Result>; - - /// KillOnlyUsers property - #[dbus_proxy(property)] - fn kill_only_users(&self) -> zbus::Result>; - - /// KillUserProcesses property - #[dbus_proxy(property)] - fn kill_user_processes(&self) -> zbus::Result; - - /// LidClosed property - #[dbus_proxy(property)] - fn lid_closed(&self) -> zbus::Result; - - /// NAutoVTs property - #[dbus_proxy(property)] - fn nauto_vts(&self) -> zbus::Result; - - /// NCurrentInhibitors property - #[dbus_proxy(property)] - fn ncurrent_inhibitors(&self) -> zbus::Result; - - /// NCurrentSessions property - #[dbus_proxy(property)] - fn ncurrent_sessions(&self) -> zbus::Result; - - /// OnExternalPower property - #[dbus_proxy(property)] - fn on_external_power(&self) -> zbus::Result; - - /// PreparingForShutdown property - #[dbus_proxy(property)] - fn preparing_for_shutdown(&self) -> zbus::Result; - - /// PreparingForSleep property - #[dbus_proxy(property)] - fn preparing_for_sleep(&self) -> zbus::Result; - - /// RebootParameter property - #[dbus_proxy(property)] - fn reboot_parameter(&self) -> zbus::Result; - - /// RebootToBootLoaderEntry property - #[dbus_proxy(property)] - fn reboot_to_boot_loader_entry(&self) -> zbus::Result; - - /// RebootToBootLoaderMenu property - #[dbus_proxy(property)] - fn reboot_to_boot_loader_menu(&self) -> zbus::Result; - - /// RebootToFirmwareSetup property - #[dbus_proxy(property)] - fn reboot_to_firmware_setup(&self) -> zbus::Result; - - /// RemoveIPC property - #[dbus_proxy(property)] - fn remove_ipc(&self) -> zbus::Result; - - /// RuntimeDirectoryInodesMax property - #[dbus_proxy(property)] - fn runtime_directory_inodes_max(&self) -> zbus::Result; - - /// RuntimeDirectorySize property - #[dbus_proxy(property)] - fn runtime_directory_size(&self) -> zbus::Result; - - // /// ScheduledShutdown property - // #[dbus_proxy(property)] - // fn scheduled_shutdown(&self) -> zbus::Result<(String, u64)>; - - /// SessionsMax property - #[dbus_proxy(property)] - fn sessions_max(&self) -> zbus::Result; - - /// UserStopDelayUSec property - #[dbus_proxy(property)] - fn user_stop_delay_usec(&self) -> zbus::Result; - - /// WallMessage property - #[dbus_proxy(property)] - fn wall_message(&self) -> zbus::Result; - // #[DBusProxy(property)] - // fn set_wall_message(&self, value: &str) -> zbus::Result<()>; -} diff --git a/logind-zbus/src/proxy/mod.rs b/logind-zbus/src/proxy/mod.rs deleted file mode 100644 index fb1b4de3..00000000 --- a/logind-zbus/src/proxy/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod logind; -pub mod session; \ No newline at end of file diff --git a/logind-zbus/src/proxy/session.rs b/logind-zbus/src/proxy/session.rs deleted file mode 100644 index b01137cf..00000000 --- a/logind-zbus/src/proxy/session.rs +++ /dev/null @@ -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; - - /// Audit property - #[dbus_proxy(property)] - fn audit(&self) -> zbus::Result; - - /// Class property - #[dbus_proxy(property)] - fn class(&self) -> zbus::Result; - - /// Desktop property - #[dbus_proxy(property)] - fn desktop(&self) -> zbus::Result; - - /// Display property - #[dbus_proxy(property)] - fn display(&self) -> zbus::Result; - - /// Id property - #[dbus_proxy(property)] - fn id(&self) -> zbus::Result; - - /// IdleHint property - #[dbus_proxy(property)] - fn idle_hint(&self) -> zbus::Result; - - /// IdleSinceHint property - #[dbus_proxy(property)] - fn idle_since_hint(&self) -> zbus::Result; - - /// IdleSinceHintMonotonic property - #[dbus_proxy(property)] - fn idle_since_hint_monotonic(&self) -> zbus::Result; - - /// Leader property - #[dbus_proxy(property)] - fn leader(&self) -> zbus::Result; - - /// LockedHint property - #[dbus_proxy(property)] - fn locked_hint(&self) -> zbus::Result; - - /// Name property - #[dbus_proxy(property)] - fn name(&self) -> zbus::Result; - - /// Remote property - #[dbus_proxy(property)] - fn remote(&self) -> zbus::Result; - - /// RemoteHost property - #[dbus_proxy(property)] - fn remote_host(&self) -> zbus::Result; - - /// RemoteUser property - #[dbus_proxy(property)] - fn remote_user(&self) -> zbus::Result; - - /// Scope property - #[dbus_proxy(property)] - fn scope(&self) -> zbus::Result; - - // /// Seat property - // #[dbus_proxy(property)] - // fn seat(&self) -> zbus::Result; - - /// Service property - #[dbus_proxy(property)] - fn service(&self) -> zbus::Result; - - /// State property - #[dbus_proxy(property)] - fn state(&self) -> zbus::Result; - - /// TTY property - #[dbus_proxy(property)] - fn tty(&self) -> zbus::Result; - - /// Timestamp property - #[dbus_proxy(property)] - fn timestamp(&self) -> zbus::Result; - - /// TimestampMonotonic property - #[dbus_proxy(property)] - fn timestamp_monotonic(&self) -> zbus::Result; - - /// Type property - #[dbus_proxy(property)] - fn type_(&self) -> zbus::Result; - - // /// User property - // #[dbus_proxy(property)] - // fn user(&self) -> zbus::Result<(u32, zvariant::OwnedObjectPath)>; - - /// VTNr property - #[dbus_proxy(property)] - fn vtnr(&self) -> zbus::Result; -} diff --git a/logind-zbus/src/types/logind.rs b/logind-zbus/src/types/logind.rs deleted file mode 100644 index 773df6fe..00000000 --- a/logind-zbus/src/types/logind.rs +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/logind-zbus/src/types/mod.rs b/logind-zbus/src/types/mod.rs deleted file mode 100644 index 064cd81a..00000000 --- a/logind-zbus/src/types/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod logind; -pub mod session; diff --git a/logind-zbus/src/types/session.rs b/logind-zbus/src/types/session.rs deleted file mode 100644 index 3a6f5876..00000000 --- a/logind-zbus/src/types/session.rs +++ /dev/null @@ -1,24 +0,0 @@ -#[derive(Debug, PartialEq)] -pub enum SessionType { - X11, - Wayland, - TTY, - Other(String), -} - -impl From for SessionType { - fn from(s: String) -> Self { - ::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()), - } - } -} \ No newline at end of file From cec40168622c084c0238305d03582ec7cbbc1de4 Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Tue, 16 Mar 2021 21:06:18 +1300 Subject: [PATCH 6/6] Refactored gfx switch session monitor --- CHANGELOG.md | 5 + Cargo.lock | 233 ++++++++++++++++++++++++++++------ asusctl/src/main.rs | 40 +++--- daemon/Cargo.toml | 5 +- daemon/src/config.rs | 10 +- daemon/src/ctrl_anime.rs | 3 +- daemon/src/ctrl_charge.rs | 3 +- daemon/src/ctrl_fan_cpu.rs | 3 +- daemon/src/ctrl_gfx/gfx.rs | 94 +++++++++----- daemon/src/ctrl_leds.rs | 4 +- daemon/src/ctrl_rog_bios.rs | 6 +- daemon/src/ctrl_supported.rs | 4 +- daemon/src/daemon.rs | 3 +- daemon/src/error.rs | 14 +- daemon/src/laptops.rs | 20 ++- daemon/src/lib.rs | 2 - daemon/src/session_manager.rs | 175 ------------------------- 17 files changed, 317 insertions(+), 307 deletions(-) delete mode 100644 daemon/src/session_manager.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f315ada..8f60eec8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +# [3.1.7] - 2021-03-11 +### Changed +- Refactor many parts of daemon +- Switch out session monitoring to logind-zbus + # [3.1.6] - 2021-03-11 ### Changed - Graphics switching will now wait until all users logged out before switching diff --git a/Cargo.lock b/Cargo.lock index 233af7a4..8407b4bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,6 +64,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "async-lock" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1996609732bde4a9988bc42125f55f2af5f3c36370e27c778d5191a4a1b63bfb" +dependencies = [ + "event-listener", +] + [[package]] name = "atty" version = "0.2.14" @@ -187,11 +196,12 @@ dependencies = [ [[package]] name = "daemon" -version = "3.1.6" +version = "3.1.7" dependencies = [ "env_logger", "intel-pstate", "log", + "logind-zbus", "rog_dbus", "rog_fan_curve", "rog_types", @@ -202,7 +212,7 @@ dependencies = [ "sysfs-class", "toml", "udev", - "zbus", + "zbus 2.0.0-beta.3", "zvariant", ] @@ -214,7 +224,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", ] [[package]] @@ -246,7 +256,7 @@ checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", ] [[package]] @@ -272,10 +282,16 @@ dependencies = [ "proc-macro2", "quote 1.0.9", "rustversion", - "syn 1.0.63", + "syn 1.0.64", "synstructure", ] +[[package]] +name = "event-listener" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" + [[package]] name = "fastrand" version = "1.4.0" @@ -357,7 +373,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", ] [[package]] @@ -403,6 +419,17 @@ dependencies = [ "wasi 0.9.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", +] + [[package]] name = "gumdrop" version = "0.8.0" @@ -420,7 +447,7 @@ checksum = "915ef07c710d84733522461de2a734d4d62a3fd39a4d4f404c2f385ef8618d05" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", ] [[package]] @@ -432,6 +459,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "humantime" version = "2.1.0" @@ -471,9 +504,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" +checksum = "538c092e5586f4cdd7dd8078c4a79220e3e168880218124dcbce860f0ea938c6" [[package]] name = "libudev-sys" @@ -506,6 +539,20 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "logind-zbus" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6671f6cf88b63e9d63009f4f6f8826fcc265c51a9977e4c7dc1263d743e0dfbb" +dependencies = [ + "serde", + "serde_json", + "zbus 2.0.0-beta.3", + "zbus_macros 2.0.0-beta.3", + "zvariant", + "zvariant_derive", +] + [[package]] name = "mac-notification-sys" version = "0.3.0" @@ -556,6 +603,18 @@ dependencies = [ "void", ] +[[package]] +name = "nix" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" +dependencies = [ + "bitflags 1.2.1", + "cc", + "cfg-if 1.0.0", + "libc", +] + [[package]] name = "nom" version = "5.1.2" @@ -575,7 +634,7 @@ dependencies = [ "mac-notification-sys", "serde", "winrt-notification", - "zbus", + "zbus 1.8.0", "zvariant", "zvariant_derive", ] @@ -677,6 +736,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + [[package]] name = "proc-macro-crate" version = "0.1.5" @@ -695,7 +760,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", "version_check", ] @@ -746,6 +811,46 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom 0.2.2", +] + +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core", +] + [[package]] name = "redox_syscall" version = "0.1.57" @@ -758,16 +863,16 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom", + "getrandom 0.1.16", "redox_syscall", "rust-argon2", ] [[package]] name = "regex" -version = "1.4.4" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54fd1046a3107eb58f42de31d656fee6853e5d276c455fd943742dce89fc3dd3" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" dependencies = [ "aho-corasick", "memchr", @@ -787,8 +892,8 @@ dependencies = [ "rog_fan_curve", "rog_types", "serde_json", - "zbus", - "zbus_macros", + "zbus 1.8.0", + "zbus_macros 1.8.0", "zvariant", ] @@ -870,7 +975,7 @@ checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", ] [[package]] @@ -892,15 +997,30 @@ checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", ] +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + [[package]] name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +[[package]] +name = "slotmap" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3003725ae562cf995f3dc82bb99e70926e09000396816765bb6d7adbe740b1" +dependencies = [ + "version_check", +] + [[package]] name = "smart-default" version = "0.6.0" @@ -909,7 +1029,7 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", ] [[package]] @@ -952,9 +1072,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd9bc7ccc2688b3344c2f48b9b546648b25ce0b20fc717ee7fa7981a8ca9717" +checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" dependencies = [ "proc-macro2", "quote 1.0.9", @@ -978,7 +1098,7 @@ checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", "unicode-xid 0.2.1", ] @@ -1002,12 +1122,11 @@ dependencies = [ [[package]] name = "time" -version = "0.1.44" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "wasi 0.10.0+wasi-snapshot-preview1", "winapi", ] @@ -1066,9 +1185,9 @@ checksum = "eafc1b9b2dfc6f5529177b62cf806484db55b32dc7c9658a118e11bbeb33061d" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "void" @@ -1090,9 +1209,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wepoll-sys" @@ -1187,13 +1306,41 @@ dependencies = [ "fastrand", "futures", "nb-connect", - "nix", + "nix 0.17.0", "once_cell", "polling", "scoped-tls", "serde", "serde_repr", - "zbus_macros", + "zbus_macros 1.8.0", + "zvariant", +] + +[[package]] +name = "zbus" +version = "2.0.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e1e656194618d167524f97e88ff9bf87f2b1e8bf58f357b2a7abfdff8cc85c9" +dependencies = [ + "async-io", + "async-lock", + "byteorder", + "derivative", + "enumflags2", + "event-listener", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "nix 0.19.1", + "once_cell", + "rand", + "scoped-tls", + "serde", + "serde_repr", + "sha1", + "slotmap", + "zbus_macros 2.0.0-beta.3", "zvariant", ] @@ -1206,14 +1353,26 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", +] + +[[package]] +name = "zbus_macros" +version = "2.0.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcd4cb372bc2cade3f2323e4104112dceb6819f5dd9afa98515b4e821d232932" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote 1.0.9", + "syn 1.0.64", ] [[package]] name = "zvariant" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fc67d552ac18ccd9e440f062f5b32c46776f96073122a8da2fe0c533833a213" +checksum = "678e7262502a135f49b1ece65010526649be7ee68acb80e1fc5377fc71fef878" dependencies = [ "byteorder", "enumflags2", @@ -1223,12 +1382,12 @@ dependencies = [ [[package]] name = "zvariant_derive" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaee686340b5bff077d52423d8cc4f0f7cb323fe3f31ef676b8a3a2810bc53c5" +checksum = "27d7c34325a35020b94343389cc9391e0f8ac245cca9155429c4022d93141241" dependencies = [ "proc-macro-crate", "proc-macro2", "quote 1.0.9", - "syn 1.0.63", + "syn 1.0.64", ] diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index ee66a6a1..d78371e2 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -4,7 +4,13 @@ use daemon::{ }; use gumdrop::{Opt, Options}; use rog_dbus::AuraDbusClient; -use rog_types::{anime_matrix::{AniMeDataBuffer, FULL_PANE_LEN}, aura_modes::AuraModes, cli_options::{AniMeActions, AniMeStatusValue, LedBrightness, SetAuraBuiltin}, gfx_vendors::GfxVendors, profile::{FanLevel, ProfileCommand, ProfileEvent}}; +use rog_types::{ + anime_matrix::{AniMeDataBuffer, FULL_PANE_LEN}, + aura_modes::AuraModes, + cli_options::{AniMeActions, AniMeStatusValue, LedBrightness, SetAuraBuiltin}, + gfx_vendors::GfxVendors, + profile::{FanLevel, ProfileCommand, ProfileEvent}, +}; use std::env::args; use yansi_term::Colour::Green; use yansi_term::Colour::Red; @@ -199,7 +205,7 @@ fn main() -> Result<(), Box> { if parsed.show_supported { let dat = dbus.proxies().supported().get_supported_functions()?; - println!("Supported laptop functions:\n{}", dat.to_string()); + println!("Supported laptop functions:\n{}", dat); } if let Some(fan_level) = parsed.fan_mode { @@ -272,11 +278,9 @@ fn do_gfx( } if let Some(mode) = command.mode { - if supported.dedicated_gfx_toggle { - if dbus.proxies().rog_bios().get_dedicated_gfx()? == 1 { - println!("You can not change modes until you turn dedicated/G-Sync off and reboot"); - std::process::exit(-1); - } + if supported.dedicated_gfx_toggle && dbus.proxies().rog_bios().get_dedicated_gfx()? == 1 { + println!("You can not change modes until you turn dedicated/G-Sync off and reboot"); + std::process::exit(-1); } println!( @@ -296,9 +300,9 @@ fn do_gfx( if command.pow { let res = dbus.proxies().gfx().gfx_get_pwr()?; if res.contains("active") { - println!("Current power status: {}", Red.paint(&format!("{}", res))); + println!("Current power status: {}", Red.paint(&res)); } else { - println!("Current power status: {}", Green.paint(&format!("{}", res))); + println!("Current power status: {}", Green.paint(&res)); } } Ok(()) @@ -347,7 +351,9 @@ fn handle_led_mode( println!("{}", mode.self_usage()); return Ok(()); } - dbus.proxies().led().set_led_mode(&::from(mode))?; + dbus.proxies() + .led() + .set_led_mode(&::from(mode))?; } Ok(()) } @@ -375,7 +381,7 @@ fn handle_profile( .collect(); for line in usage .iter() - .filter(|line| !(line.contains("--curve") && !supported.fan_curve_set)) + .filter(|line| !line.contains("--curve") || supported.fan_curve_set) { println!("{}", line); } @@ -427,11 +433,7 @@ fn handle_bios_option( dbus.proxies().rog_bios().set_post_sound(opt)?; } if cmd.post_sound_get { - let res = if dbus.proxies().rog_bios().get_post_sound()? == 1 { - true - } else { - false - }; + let res = dbus.proxies().rog_bios().get_post_sound()? == 1; println!("Bios POST sound on: {}", res); } if let Some(opt) = cmd.dedicated_gfx_set { @@ -447,11 +449,7 @@ fn handle_bios_option( } } if cmd.dedicated_gfx_get { - let res = if dbus.proxies().rog_bios().get_dedicated_gfx()? == 1 { - true - } else { - false - }; + let res = dbus.proxies().rog_bios().get_dedicated_gfx()? == 1; println!("Bios dedicated GPU on: {}", res); } } diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index 3a2425a1..99a2f756 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "daemon" -version = "3.1.6" +version = "3.1.7" license = "MPL-2.0" readme = "README.md" authors = ["Luke "] @@ -27,8 +27,9 @@ udev = "^0.6" log = "^0.4" env_logger = "^0.8" -zbus = "^1.8" +zbus = "^2.0.0-beta.3" zvariant = "^2.5" +logind-zbus = "*" # serialisation serde = "^1.0" diff --git a/daemon/src/config.rs b/daemon/src/config.rs index 3c90b615..24226a9e 100644 --- a/daemon/src/config.rs +++ b/daemon/src/config.rs @@ -56,10 +56,12 @@ impl Config { .write(true) .create(true) .open(&CONFIG_PATH) - .expect(&format!( - "The file {} or directory /etc/asusd/ is missing", - CONFIG_PATH - )); // okay to cause panic here + .unwrap_or_else(|_| { + panic!( + "The file {} or directory /etc/asusd/ is missing", + CONFIG_PATH + ) + }); // okay to cause panic here let mut buf = String::new(); if let Ok(read_len) = file.read_to_string(&mut buf) { if read_len == 0 { diff --git a/daemon/src/ctrl_anime.rs b/daemon/src/ctrl_anime.rs index 414a9c22..09de479f 100644 --- a/daemon/src/ctrl_anime.rs +++ b/daemon/src/ctrl_anime.rs @@ -21,7 +21,6 @@ use rog_types::{ error::AuraError, }; use rusb::{Device, DeviceHandle}; -use std::convert::TryInto; use std::error::Error; use std::time::Duration; use zbus::dbus_interface; @@ -60,7 +59,7 @@ pub trait Dbus { impl crate::ZbusAdd for CtrlAnimeDisplay { fn add_to_server(self, server: &mut zbus::ObjectServer) { server - .at(&"/org/asuslinux/Anime".try_into().unwrap(), self) + .at("/org/asuslinux/Anime", self) .map_err(|err| { warn!("CtrlAnimeDisplay: add_to_server {}", err); err diff --git a/daemon/src/ctrl_charge.rs b/daemon/src/ctrl_charge.rs index 65bb5a11..56e577da 100644 --- a/daemon/src/ctrl_charge.rs +++ b/daemon/src/ctrl_charge.rs @@ -2,7 +2,6 @@ use crate::{config::Config, error::RogError, GetSupported}; //use crate::dbus::DbusEvents; use log::{info, warn}; use serde_derive::{Deserialize, Serialize}; -use std::convert::TryInto; use std::fs::OpenOptions; use std::io::Write; use std::path::Path; @@ -64,7 +63,7 @@ impl CtrlCharge { impl crate::ZbusAdd for CtrlCharge { fn add_to_server(self, server: &mut zbus::ObjectServer) { server - .at(&"/org/asuslinux/Charge".try_into().unwrap(), self) + .at("/org/asuslinux/Charge", self) .map_err(|err| { warn!("CtrlCharge: add_to_server {}", err); err diff --git a/daemon/src/ctrl_fan_cpu.rs b/daemon/src/ctrl_fan_cpu.rs index da064c8c..5dc7599f 100644 --- a/daemon/src/ctrl_fan_cpu.rs +++ b/daemon/src/ctrl_fan_cpu.rs @@ -6,7 +6,6 @@ use crate::{ use log::{info, warn}; use rog_types::profile::{FanLevel, ProfileEvent}; use serde_derive::{Deserialize, Serialize}; -use std::convert::TryInto; use std::fs::OpenOptions; use std::io::Write; use std::path::Path; @@ -135,7 +134,7 @@ impl DbusFanAndCpu { impl crate::ZbusAdd for DbusFanAndCpu { fn add_to_server(self, server: &mut zbus::ObjectServer) { server - .at(&"/org/asuslinux/Profile".try_into().unwrap(), self) + .at("/org/asuslinux/Profile", self) .map_err(|err| { warn!("DbusFanAndCpu: add_to_server {}", err); err diff --git a/daemon/src/ctrl_gfx/gfx.rs b/daemon/src/ctrl_gfx/gfx.rs index 9340f6cb..22d3afb7 100644 --- a/daemon/src/ctrl_gfx/gfx.rs +++ b/daemon/src/ctrl_gfx/gfx.rs @@ -2,19 +2,24 @@ use ctrl_gfx::error::GfxError; use ctrl_gfx::*; use ctrl_rog_bios::CtrlRogBios; use log::{error, info, warn}; +use logind_zbus::{ + types::{SessionClass, SessionInfo, SessionType}, + ManagerProxy, SessionProxy, +}; use rog_types::gfx_vendors::GfxVendors; -use session_manager::{are_gfx_sessions_alive, get_sessions}; -use std::{io::Write, ops::Add, path::Path}; +use std::{io::Write, ops::Add, path::Path, time::Instant}; use std::{iter::FromIterator, thread::JoinHandle}; use std::{process::Command, thread::sleep, time::Duration}; use std::{str::FromStr, sync::mpsc}; use std::{sync::Arc, sync::Mutex}; use sysfs_class::{PciDevice, SysClass}; use system::{GraphicsDevice, PciBus}; -use zbus::dbus_interface; +use zbus::{dbus_interface, Connection}; use crate::*; +const THREAD_TIMEOUT_MSG: &str = "GFX: thread time exceeded 3 minutes, exiting"; + pub struct CtrlGraphics { bus: PciBus, _amd: Vec, @@ -34,8 +39,6 @@ trait Dbus { fn notify_action(&self, action: &str) -> zbus::Result<()>; } -use std::convert::TryInto; - #[dbus_interface(name = "org.asuslinux.Daemon")] impl Dbus for CtrlGraphics { fn vendor(&self) -> String { @@ -72,12 +75,7 @@ impl Dbus for CtrlGraphics { impl ZbusAdd for CtrlGraphics { fn add_to_server(self, server: &mut zbus::ObjectServer) { server - .at( - &"/org/asuslinux/Gfx" - .try_into() - .expect("Couldn't add to zbus"), - self, - ) + .at("/org/asuslinux/Gfx", self) .map_err(|err| { warn!("GFX: CtrlGraphics: add_to_server {}", err); err @@ -165,20 +163,18 @@ impl CtrlGraphics { self.nvidia.clone() } - fn save_gfx_mode(vendor: GfxVendors, config: Arc>) -> Result<(), RogError> { + fn save_gfx_mode(vendor: GfxVendors, config: Arc>) { if let Ok(mut config) = config.lock() { - config.gfx_mode = vendor.clone(); + config.gfx_mode = vendor; config.write(); - return Ok(()); } // TODO: Error here - Ok(()) } /// Associated method to get which vendor mode is set pub fn get_gfx_mode(&self) -> Result { if let Ok(config) = self.config.lock() { - return Ok(config.gfx_mode.clone()); + return Ok(config.gfx_mode); } // TODO: Error here Ok(GfxVendors::Hybrid) @@ -379,7 +375,7 @@ impl CtrlGraphics { std::thread::sleep(std::time::Duration::from_millis(500)); count += 1; } - return Err(GfxError::DisplayManagerTimeout(state.into()).into()); + Err(GfxError::DisplayManagerTimeout(state.into()).into()) } /// Write the config changes and add/remove drivers and devices depending @@ -425,34 +421,69 @@ impl CtrlGraphics { Ok(()) } + fn graphical_session_active( + connection: &Connection, + sessions: &[SessionInfo], + ) -> Result { + for session in sessions { + let session_proxy = SessionProxy::new(&connection, session)?; + if session_proxy.get_class()? == SessionClass::User { + match session_proxy.get_type()? { + SessionType::X11 | SessionType::Wayland | SessionType::MIR => { + if session_proxy.get_active()? { + return Ok(true); + } + } + _ => {} + } + } + } + Ok(false) + } + /// Spools until all user sessions are ended then switches to requested mode fn fire_starter( vendor: GfxVendors, devices: Vec, bus: PciBus, - killer: mpsc::Receiver, + thread_stop: mpsc::Receiver, ) -> Result { info!("GFX: display-manager thread started"); - let mut sessions: Vec = get_sessions()?; - const SLEEP_PERIOD: Duration = Duration::from_millis(300); - const REFRESH_COUNTDOWN: u32 = 3; - let mut refresh_sessions = REFRESH_COUNTDOWN; - while are_gfx_sessions_alive(&sessions) { - if let Ok(stop) = killer.try_recv() { + const SLEEP_PERIOD: Duration = Duration::from_millis(100); + let start_time = Instant::now(); + + let connection = Connection::new_system()?; + let manager = ManagerProxy::new(&connection)?; + let mut sessions = manager.list_sessions()?; + + loop { + let tmp = manager.list_sessions()?; + if !tmp.iter().eq(&sessions) { + warn!("GFX: Sessions list changed"); + warn!("GFX: Old list:\n{:?}\nNew list:\n{:?}", &sessions, &tmp); + sessions = tmp; + } + + if !Self::graphical_session_active(&connection, &sessions)? { + break; + } + + if let Ok(stop) = thread_stop.try_recv() { if stop { return Ok("Graphics mode change was cancelled".into()); } } + // exit if 3 minutes pass + if Instant::now().duration_since(start_time).as_secs() > 180 { + warn!("{}", THREAD_TIMEOUT_MSG); + return Ok(THREAD_TIMEOUT_MSG.into()); + } + // Don't spin at max speed sleep(SLEEP_PERIOD); - if refresh_sessions == 0 { - refresh_sessions = REFRESH_COUNTDOWN; - sessions = get_sessions()?; - } - refresh_sessions -= 1; } - + info!("GFX: all graphical user sessions ended, continuing"); Self::do_display_manager_action("stop")?; @@ -514,7 +545,7 @@ impl CtrlGraphics { let killer = self.thread_kill.clone(); // Save selected mode in case of reboot - Self::save_gfx_mode(vendor, self.config.clone())?; + Self::save_gfx_mode(vendor, self.config.clone()); let _join: JoinHandle<()> = std::thread::spawn(move || { Self::fire_starter(vendor, devices, bus, rx) @@ -526,7 +557,6 @@ impl CtrlGraphics { if let Ok(mut lock) = killer.try_lock() { *lock = None; } - return; }); // TODO: undo if failed? Save last mode, catch errors... diff --git a/daemon/src/ctrl_leds.rs b/daemon/src/ctrl_leds.rs index 3ba4e20b..e0f67ba0 100644 --- a/daemon/src/ctrl_leds.rs +++ b/daemon/src/ctrl_leds.rs @@ -18,9 +18,9 @@ use rog_types::{ }; use std::fs::OpenOptions; use std::io::{Read, Write}; +use std::path::Path; use std::sync::Arc; use std::sync::Mutex; -use std::{convert::TryInto, path::Path}; use zbus::dbus_interface; use crate::GetSupported; @@ -88,7 +88,7 @@ trait Dbus { impl crate::ZbusAdd for DbusKbdBacklight { fn add_to_server(self, server: &mut zbus::ObjectServer) { server - .at(&"/org/asuslinux/Led".try_into().unwrap(), self) + .at("/org/asuslinux/Led", self) .map_err(|err| { error!("DbusKbdBacklight: add_to_server {}", err); }) diff --git a/daemon/src/ctrl_rog_bios.rs b/daemon/src/ctrl_rog_bios.rs index 9ff1df0c..4cfdd8e4 100644 --- a/daemon/src/ctrl_rog_bios.rs +++ b/daemon/src/ctrl_rog_bios.rs @@ -2,12 +2,12 @@ use crate::{config::Config, error::RogError, GetSupported}; use log::{error, info, warn}; use serde_derive::{Deserialize, Serialize}; use std::fs::OpenOptions; +use std::io::BufRead; use std::io::{Read, Write}; use std::path::Path; use std::process::Command; use std::sync::Arc; use std::sync::Mutex; -use std::{convert::TryInto, io::BufRead}; use zbus::dbus_interface; const INITRAMFS_PATH: &str = "/usr/sbin/update-initramfs"; @@ -101,7 +101,7 @@ impl CtrlRogBios { impl crate::ZbusAdd for CtrlRogBios { fn add_to_server(self, server: &mut zbus::ObjectServer) { server - .at(&"/org/asuslinux/RogBios".try_into().unwrap(), self) + .at("/org/asuslinux/RogBios", self) .map_err(|err| { warn!("CtrlRogBios: add_to_server {}", err); err @@ -334,7 +334,7 @@ impl CtrlRogBios { .map_err(|err| RogError::Write(format!("{:?}", cmd), err))?; if !status.success() { error!("Ram disk update failed"); - return Err(RogError::Initramfs("Ram disk update failed".into()).into()); + return Err(RogError::Initramfs("Ram disk update failed".into())); } else { info!("Successfully updated initramfs"); } diff --git a/daemon/src/ctrl_supported.rs b/daemon/src/ctrl_supported.rs index 93b3642f..64d043d6 100644 --- a/daemon/src/ctrl_supported.rs +++ b/daemon/src/ctrl_supported.rs @@ -1,5 +1,3 @@ -use std::convert::TryInto; - use log::warn; use serde_derive::{Deserialize, Serialize}; use zbus::dbus_interface; @@ -32,7 +30,7 @@ impl SupportedFunctions { impl crate::ZbusAdd for SupportedFunctions { fn add_to_server(self, server: &mut zbus::ObjectServer) { server - .at(&"/org/asuslinux/Supported".try_into().unwrap(), self) + .at("/org/asuslinux/Supported", self) .map_err(|err| { warn!("SupportedFunctions: add_to_server {}", err); err diff --git a/daemon/src/daemon.rs b/daemon/src/daemon.rs index fafdbccb..a43c4623 100644 --- a/daemon/src/daemon.rs +++ b/daemon/src/daemon.rs @@ -19,7 +19,6 @@ use std::sync::Mutex; use daemon::ctrl_rog_bios::CtrlRogBios; use std::convert::Into; -use std::convert::TryInto; use zbus::fdo; use zbus::Connection; @@ -180,7 +179,7 @@ fn start_daemon() -> Result<(), Box> { }); object_server - .with(&"/org/asuslinux/Charge".try_into()?, |obj: &CtrlCharge| { + .with("/org/asuslinux/Charge", |obj: &CtrlCharge| { let x = obj.limit(); obj.notify_charge(x as u8) }) diff --git a/daemon/src/error.rs b/daemon/src/error.rs index e2f71e08..2a86675d 100644 --- a/daemon/src/error.rs +++ b/daemon/src/error.rs @@ -4,7 +4,7 @@ use rog_types::error::GraphicsError; use std::convert::From; use std::fmt; -use crate::{ctrl_gfx::error::GfxError, session_manager::SessionError}; +use crate::ctrl_gfx::error::GfxError; #[derive(Debug)] pub enum RogError { @@ -28,7 +28,7 @@ pub enum RogError { Initramfs(String), Modprobe(String), Command(String, std::io::Error), - Session(SessionError), + Zbus(zbus::Error), } impl fmt::Display for RogError { @@ -55,7 +55,7 @@ impl fmt::Display for RogError { RogError::Initramfs(detail) => write!(f, "Initiramfs error: {}", detail), RogError::Modprobe(detail) => write!(f, "Modprobe error: {}", detail), RogError::Command(func, error) => write!(f, "Command exec error: {}: {}", func, error), - RogError::Session(detail) => write!(f, "Session error: {}", detail), + RogError::Zbus(detail) => write!(f, "Zbus error: {}", detail), } } } @@ -82,8 +82,8 @@ impl From for RogError { } } -impl From for RogError { - fn from(err: SessionError) -> Self { - RogError::Session(err) +impl From for RogError { + fn from(err: zbus::Error) -> Self { + RogError::Zbus(err) } -} \ No newline at end of file +} diff --git a/daemon/src/laptops.rs b/daemon/src/laptops.rs index 8f96e22b..9b8b92f4 100644 --- a/daemon/src/laptops.rs +++ b/daemon/src/laptops.rs @@ -34,21 +34,19 @@ pub fn match_laptop() -> Option { let device_desc = device .device_descriptor() .expect("Couldn't get device descriptor"); - if device_desc.vendor_id() == 0x0b05 { - if LAPTOP_DEVICES.contains(&device_desc.product_id()) { - let prod_str = format!("{:x?}", device_desc.product_id()); + if device_desc.vendor_id() == 0x0b05 && LAPTOP_DEVICES.contains(&device_desc.product_id()) { + let prod_str = format!("{:x?}", device_desc.product_id()); - if device_desc.product_id() == 0x1854 { - let mut laptop = laptop(prod_str, None); - if laptop.supported_modes.is_empty() { - laptop.supported_modes = vec![STATIC, BREATHING]; - } - return Some(laptop); + if device_desc.product_id() == 0x1854 { + let mut laptop = laptop(prod_str, None); + if laptop.supported_modes.is_empty() { + laptop.supported_modes = vec![STATIC, BREATHING]; } - - let laptop = laptop(prod_str, Some("02".to_owned())); return Some(laptop); } + + let laptop = laptop(prod_str, Some("02".to_owned())); + return Some(laptop); } } warn!( diff --git a/daemon/src/lib.rs b/daemon/src/lib.rs index d6c16788..aa59cd58 100644 --- a/daemon/src/lib.rs +++ b/daemon/src/lib.rs @@ -30,8 +30,6 @@ pub mod laptops; /// Fetch all supported functions for the laptop pub mod ctrl_supported; -pub mod session_manager; - mod error; use crate::error::RogError; diff --git a/daemon/src/session_manager.rs b/daemon/src/session_manager.rs deleted file mode 100644 index 5244cd60..00000000 --- a/daemon/src/session_manager.rs +++ /dev/null @@ -1,175 +0,0 @@ -use log::{error, warn}; -use serde_derive::{Deserialize, Serialize}; -use std::process::Command; - -#[derive(Debug, PartialEq)] -enum SessionType { - X11, - Wayland, - TTY, -} - -#[derive(Deserialize, Serialize, Debug)] -pub struct UserSession { - pub session: String, - pub uid: u32, - pub user: String, - pub seat: String, - pub tty: String, -} - -#[derive(Debug)] -pub struct Session { - session_id: String, - session_type: SessionType, -} - -pub fn are_gfx_sessions_alive(sessions: &[Session]) -> bool { - for session in sessions { - match is_gfx_alive(session) { - Ok(alive) => { - if alive { - return true; - } - } - Err(err) => warn!("Error checking sessions: {}", err), - } - } - false -} - -pub fn get_sessions() -> Result, SessionError> { - // loginctl list-sessions --no-legend - let mut cmd = Command::new("loginctl"); - cmd.arg("list-sessions"); - cmd.arg("--output"); - cmd.arg("json"); - - let mut sessions = Vec::new(); - - match cmd.output() { - Ok(output) => { - if !output.status.success() { - error!( - "Couldn't get sessions: {}", - String::from_utf8_lossy(&output.stderr) - ); - } else if output.status.success() { - if let Ok(data) = serde_json::from_slice::>(&output.stdout) { - for s in &data { - if let Ok(t) = get_session_type(&s.session) { - sessions.push(Session { - session_id: s.session.to_owned(), - session_type: t, - }) - } - } - return Ok(sessions); - } - } - } - Err(err) => error!("Couldn't get sessions: {}", err), - } - Err(SessionError::NoSessions) -} - -fn is_gfx_alive(session: &Session) -> Result { - if session.session_type == SessionType::TTY { - return Ok(false); - } - let session_id = session.session_id.to_owned(); - let mut cmd = Command::new("loginctl"); - cmd.arg("show-session"); - cmd.arg(&session_id); - cmd.arg("--property"); - cmd.arg("Type"); - - match cmd.output() { - Ok(output) => { - if !output.status.success() { - let msg = String::from_utf8_lossy(&output.stderr); - if msg.contains("No session") { - return Ok(false); - } - error!( - "Couldn't get session: {}", - String::from_utf8_lossy(&output.stderr) - ); - } else if output.status.success() { - return Ok(true); - } - } - Err(err) => error!("Couldn't get session: {}", err), - } - Ok(false) -} - -fn get_session_type(session_id: &str) -> Result { - //loginctl show-session 2 --property Type - let mut cmd = Command::new("loginctl"); - cmd.arg("show-session"); - cmd.arg(session_id); - cmd.arg("--property"); - cmd.arg("Type"); - cmd.arg("--property"); - cmd.arg("Class"); - - match cmd.output() { - Ok(output) => { - if !output.status.success() { - let msg = String::from_utf8_lossy(&output.stderr); - if msg.contains("No session") { - return Err(SessionError::NoSession(session_id.into())); - } - error!( - "Couldn't get session: {}", - String::from_utf8_lossy(&output.stderr) - ); - } else if output.status.success() { - let what = String::from_utf8_lossy(&output.stdout); - let mut stype = SessionType::TTY; - let mut user = false; - for line in what.lines() { - if let Some(is_it) = line.split("=").last() { - match is_it.trim() { - "user" => user = true, - "wayland" => stype = SessionType::Wayland, - "x11" => stype = SessionType::X11, - "tty" => stype = SessionType::TTY, - _ => return Err(SessionError::NoSession(session_id.into())), - } - } - } - if user { - return Ok(stype); - } - } - } - Err(err) => error!("Couldn't get session: {}", err), - } - Err(SessionError::NoSession(session_id.into())) -} - -use std::fmt; - -#[derive(Debug)] -pub enum SessionError { - NoSession(String), - NoSessions, - Command(String, std::io::Error), -} - -impl fmt::Display for SessionError { - // This trait requires `fmt` with this exact signature. - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - SessionError::NoSession(id) => write!(f, "Session {} not active", id), - SessionError::NoSessions => write!(f, "No active sessions"), - SessionError::Command(func, error) => { - write!(f, "Command exec error: {}: {}", func, error) - } - } - } -} - -impl std::error::Error for SessionError {}