diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index c21c5733..4f414d50 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -431,7 +431,10 @@ fn handle_profile( println!("Available profiles are {:?}", profile_names); } if cmd.active_name { - println!("Active profile: {:?}", dbus.proxies().profile().active_profile_name()?); + println!( + "Active profile: {:?}", + dbus.proxies().profile().active_profile_name()? + ); } if cmd.active_data { println!("Active profile:"); diff --git a/daemon/src/config_old.rs b/daemon/src/config_old.rs index 9d2b3a08..0e307617 100644 --- a/daemon/src/config_old.rs +++ b/daemon/src/config_old.rs @@ -2,7 +2,7 @@ use rog_types::{aura_modes::AuraEffect, gfx_vendors::GfxVendors, profile::Profil use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; -use crate::config::{Config}; +use crate::config::Config; /// for parsing old v2.1.2 config #[allow(dead_code)] diff --git a/daemon/src/ctrl_fan_cpu.rs b/daemon/src/ctrl_fan_cpu.rs index 9c09c403..a3a67302 100644 --- a/daemon/src/ctrl_fan_cpu.rs +++ b/daemon/src/ctrl_fan_cpu.rs @@ -1,10 +1,7 @@ use crate::error::RogError; -use crate::{ - config::{Config}, - GetSupported, -}; +use crate::{config::Config, GetSupported}; use log::{info, warn}; -use rog_types::profile::{FanLevel, ProfileEvent, Profile}; +use rog_types::profile::{FanLevel, Profile, ProfileEvent}; use serde_derive::{Deserialize, Serialize}; use std::fs::OpenOptions; use std::io::Write; @@ -97,7 +94,9 @@ impl DbusFanAndCpu { return Ok(cfg.active_profile.clone()); } } - Err(Error::Failed("Failed to get active profile name".to_string())) + Err(Error::Failed( + "Failed to get active profile name".to_string(), + )) } // TODO: Profile can't implement Type because of Curve @@ -113,7 +112,9 @@ impl DbusFanAndCpu { } } } - Err(Error::Failed("Failed to get active profile details".to_string())) + Err(Error::Failed( + "Failed to get active profile details".to_string(), + )) } /// Fetch all profile data @@ -126,18 +127,16 @@ impl DbusFanAndCpu { } } } - Err(Error::Failed("Failed to get all profile details".to_string())) + Err(Error::Failed( + "Failed to get all profile details".to_string(), + )) } fn profile_names(&self) -> zbus::fdo::Result> { if let Ok(ctrl) = self.inner.try_lock() { if let Ok(mut cfg) = ctrl.config.try_lock() { cfg.read(); - let profile_names = cfg - .power_profiles - .keys() - .cloned() - .collect::>(); + let profile_names = cfg.power_profiles.keys().cloned().collect::>(); return Ok(profile_names); } } diff --git a/daemon/src/ctrl_gfx/error.rs b/daemon/src/ctrl_gfx/error.rs index ac833bea..9030f02f 100644 --- a/daemon/src/ctrl_gfx/error.rs +++ b/daemon/src/ctrl_gfx/error.rs @@ -34,10 +34,7 @@ impl fmt::Display for GfxError { f, "Can not switch to vfio mode if the modules are built in to kernel" ), - GfxError::MissingModule(m) => write!( - f, - "The module {} is missing", m - ), + GfxError::MissingModule(m) => write!(f, "The module {} is missing", m), } } } diff --git a/daemon/src/ctrl_gfx/gfx.rs b/daemon/src/ctrl_gfx/gfx.rs index a0a8d3ff..d7a978b5 100644 --- a/daemon/src/ctrl_gfx/gfx.rs +++ b/daemon/src/ctrl_gfx/gfx.rs @@ -2,7 +2,10 @@ use ctrl_gfx::error::GfxError; use ctrl_gfx::*; use ctrl_rog_bios::CtrlRogBios; use log::{error, info, warn}; -use logind_zbus::{ManagerProxy, SessionProxy, types::{SessionClass, SessionInfo, SessionState, SessionType}}; +use logind_zbus::{ + types::{SessionClass, SessionInfo, SessionState, SessionType}, + ManagerProxy, SessionProxy, +}; use rog_types::gfx_vendors::{GfxRequiredUserAction, GfxVendors}; use std::sync::mpsc; use std::{io::Write, ops::Add, path::Path, time::Instant}; @@ -323,10 +326,7 @@ impl CtrlGraphics { { return Ok(()); } - if output - .stderr - .ends_with("is builtin.\n".as_bytes()) - { + if output.stderr.ends_with("is builtin.\n".as_bytes()) { return Err(GfxError::VfioBuiltin.into()); } if output.stderr.ends_with("Permission denied\n".as_bytes()) { @@ -339,7 +339,9 @@ impl CtrlGraphics { warn!("GFX: It may be safe to ignore the above error, run `lsmod |grep {}` to confirm modules loaded", driver); return Ok(()); } - if String::from_utf8_lossy(&output.stderr).contains(&format!("Module {} not found", driver)) { + if String::from_utf8_lossy(&output.stderr) + .contains(&format!("Module {} not found", driver)) + { return Err(GfxError::MissingModule(driver.into()).into()); } if count >= MAX_TRIES { @@ -445,6 +447,7 @@ impl CtrlGraphics { } } GfxVendors::Vfio => { + Self::do_driver_action("nouveau", "rmmod")?; for driver in NVIDIA_DRIVERS.iter() { Self::do_driver_action(driver, "rmmod")?; } @@ -452,6 +455,7 @@ impl CtrlGraphics { Self::do_driver_action("vfio-pci", "modprobe")?; } GfxVendors::Integrated => { + Self::do_driver_action("nouveau", "rmmod")?; for driver in VFIO_DRIVERS.iter() { Self::do_driver_action(driver, "rmmod")?; } @@ -539,7 +543,7 @@ impl CtrlGraphics { info!("GFX thread: display-manager started"); let v: &str = vendor.into(); - info!("GFX: Graphics mode changed to {} successfully", v); + info!("GFX thread: Graphics mode changed to {} successfully", v); Ok(format!("Graphics mode changed to {} successfully", v)) } @@ -609,6 +613,7 @@ impl CtrlGraphics { let devices = self.nvidia.clone(); let bus = self.bus.clone(); Self::do_vendor_tasks(vendor, &devices, &bus)?; + info!("GFX: Graphics mode changed to {}", <&str>::from(vendor)); } // TODO: undo if failed? Save last mode, catch errors... Ok(action_required) diff --git a/rog-types/src/profile.rs b/rog-types/src/profile.rs index 4ac78d79..a181c186 100644 --- a/rog-types/src/profile.rs +++ b/rog-types/src/profile.rs @@ -3,7 +3,6 @@ use rog_fan_curve::{Curve, Fan}; use serde_derive::{Deserialize, Serialize}; use std::str::FromStr; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Profile { pub min_percentage: u8,