mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Changed
|
### Changed
|
||||||
- Fix missing CLI command help for some supported options
|
- Fix missing CLI command help for some supported options
|
||||||
|
- Fix incorrectly selecting profile by name, where the active profile was being copied to the selected profile
|
||||||
|
|
||||||
# [3.7.1] - 2021-06-11
|
# [3.7.1] - 2021-06-11
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -489,12 +489,21 @@ fn handle_profile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut set_profile = false;
|
let mut set_profile = false;
|
||||||
let mut profile;
|
let mut profile = Profile::default();
|
||||||
if cmd.create {
|
if cmd.create {
|
||||||
profile = Profile::default();
|
|
||||||
set_profile = true;
|
set_profile = true;
|
||||||
} else {
|
} else if let Some(ref name) = cmd.profile {
|
||||||
profile = dbus.proxies().profile().active_data()?;
|
let profiles = dbus.proxies().profile().all_profile_data()?;
|
||||||
|
for p in profiles {
|
||||||
|
if p.name == *name {
|
||||||
|
profile = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if profile.name != *name {
|
||||||
|
println!("The requested profile doesn't exist, you may need to create it");
|
||||||
|
std::process::exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(turbo) = cmd.turbo {
|
if let Some(turbo) = cmd.turbo {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::error::RogError;
|
use crate::error::RogError;
|
||||||
use crate::{config::Config, GetSupported};
|
use crate::{config::Config, GetSupported};
|
||||||
use log::info;
|
use log::{info, warn};
|
||||||
|
use rog_profiles::error::ProfileError;
|
||||||
use rog_profiles::profiles::Profile;
|
use rog_profiles::profiles::Profile;
|
||||||
use rog_types::supported::FanCpuSupportedFunctions;
|
use rog_types::supported::FanCpuSupportedFunctions;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -23,12 +24,12 @@ impl GetSupported for CtrlFanAndCpu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Reloadable for CtrlFanAndCpu {
|
impl crate::Reloadable for CtrlFanAndCpu {
|
||||||
|
/// Fetcht he active profile and use that to set all related components up
|
||||||
fn reload(&mut self) -> Result<(), RogError> {
|
fn reload(&mut self) -> Result<(), RogError> {
|
||||||
if let Ok(mut cfg) = self.config.clone().try_lock() {
|
if let Ok(mut cfg) = self.config.clone().try_lock() {
|
||||||
let active = cfg.active_profile.clone();
|
let active = cfg.active_profile.clone();
|
||||||
if let Some(existing) = cfg.power_profiles.get_mut(&active) {
|
if let Some(existing) = cfg.power_profiles.get_mut(&active) {
|
||||||
existing.set_system_all()?;
|
existing.set_system_all()?;
|
||||||
cfg.write();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -38,31 +39,38 @@ impl crate::Reloadable for CtrlFanAndCpu {
|
|||||||
impl CtrlFanAndCpu {
|
impl CtrlFanAndCpu {
|
||||||
pub fn new(config: Arc<Mutex<Config>>) -> Result<Self, RogError> {
|
pub fn new(config: Arc<Mutex<Config>>) -> Result<Self, RogError> {
|
||||||
Profile::get_fan_path()?;
|
Profile::get_fan_path()?;
|
||||||
info!("Device has thermal throttle control");
|
info!("Device has fan control available");
|
||||||
Ok(CtrlFanAndCpu { config })
|
Ok(CtrlFanAndCpu { config })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Toggle to next profile in list
|
/// Toggle to next profile in list
|
||||||
pub(super) fn do_next_profile(&mut self) -> Result<(), RogError> {
|
pub(super) fn do_next_profile(&mut self) -> Result<(), RogError> {
|
||||||
if let Ok(mut config) = self.config.clone().try_lock() {
|
if let Ok(mut config) = self.config.clone().try_lock() {
|
||||||
|
// Read first just incase the user has modified the config before calling this
|
||||||
config.read();
|
config.read();
|
||||||
|
|
||||||
let mut i = config
|
let mut toggle_index = config
|
||||||
.toggle_profiles
|
.toggle_profiles
|
||||||
.binary_search(&config.active_profile)
|
.binary_search(&config.active_profile)
|
||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
+ 1;
|
+ 1;
|
||||||
if i >= config.toggle_profiles.len() {
|
if toggle_index >= config.toggle_profiles.len() {
|
||||||
i = 0;
|
toggle_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let profile = config.toggle_profiles[i].clone();
|
let profile = config.toggle_profiles[toggle_index].clone();
|
||||||
|
|
||||||
if let Some(existing) = config.power_profiles.get(&profile) {
|
if let Some(existing) = config.power_profiles.get(&profile) {
|
||||||
existing.set_system_all()?;
|
existing.set_system_all()?;
|
||||||
config.active_profile = existing.name.clone();
|
config.active_profile = existing.name.clone();
|
||||||
config.write();
|
config.write();
|
||||||
info!("Profile was changed to: {}", profile);
|
info!("Profile was changed to: {}", &profile);
|
||||||
|
} else {
|
||||||
|
warn!(
|
||||||
|
"toggle_profile {} does not exist in power_profiles",
|
||||||
|
&profile
|
||||||
|
);
|
||||||
|
return Err(RogError::MissingProfile(profile.to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -70,17 +78,25 @@ impl CtrlFanAndCpu {
|
|||||||
|
|
||||||
pub(super) fn set_active(&mut self, profile: &str) -> Result<(), RogError> {
|
pub(super) fn set_active(&mut self, profile: &str) -> Result<(), RogError> {
|
||||||
if let Ok(mut config) = self.config.clone().try_lock() {
|
if let Ok(mut config) = self.config.clone().try_lock() {
|
||||||
|
// Read first just incase the user has modified the config before calling this
|
||||||
config.read();
|
config.read();
|
||||||
if let Some(existing) = config.power_profiles.get(profile) {
|
if let Some(existing) = config.power_profiles.get(profile) {
|
||||||
existing.set_system_all()?;
|
existing.set_system_all()?;
|
||||||
config.active_profile = existing.name.clone();
|
config.active_profile = existing.name.clone();
|
||||||
config.write();
|
config.write();
|
||||||
info!("Profile was changed to: {}", profile);
|
info!("Profile was changed to: {}", profile);
|
||||||
|
} else {
|
||||||
|
warn!(
|
||||||
|
"toggle_profile {} does not exist in power_profiles",
|
||||||
|
profile
|
||||||
|
);
|
||||||
|
return Err(RogError::MissingProfile(profile.to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new profile if the requested name doesn't exist, or modify existing
|
||||||
pub(super) fn new_or_modify(&mut self, profile: &Profile) -> Result<(), RogError> {
|
pub(super) fn new_or_modify(&mut self, profile: &Profile) -> Result<(), RogError> {
|
||||||
if let Ok(mut config) = self.config.clone().try_lock() {
|
if let Ok(mut config) = self.config.clone().try_lock() {
|
||||||
config.read();
|
config.read();
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use crate::ctrl_gfx::error::GfxError;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum RogError {
|
pub enum RogError {
|
||||||
ParseFanLevel,
|
|
||||||
ParseVendor,
|
ParseVendor,
|
||||||
ParseLed,
|
ParseLed,
|
||||||
MissingProfile(String),
|
MissingProfile(String),
|
||||||
@@ -36,7 +35,6 @@ impl fmt::Display for RogError {
|
|||||||
// This trait requires `fmt` with this exact signature.
|
// This trait requires `fmt` with this exact signature.
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
RogError::ParseFanLevel => write!(f, "Parse profile error"),
|
|
||||||
RogError::ParseVendor => write!(f, "Parse gfx vendor error"),
|
RogError::ParseVendor => write!(f, "Parse gfx vendor error"),
|
||||||
RogError::ParseLed => write!(f, "Parse LED error"),
|
RogError::ParseLed => write!(f, "Parse LED error"),
|
||||||
RogError::MissingProfile(profile) => write!(f, "Profile does not exist {}", profile),
|
RogError::MissingProfile(profile) => write!(f, "Profile does not exist {}", profile),
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use rog_fan_curve::CurveError;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ProfileError {
|
pub enum ProfileError {
|
||||||
ParseFanLevel,
|
ParseFanLevel,
|
||||||
MissingProfile(String),
|
|
||||||
Path(String, std::io::Error),
|
Path(String, std::io::Error),
|
||||||
Read(String, std::io::Error),
|
Read(String, std::io::Error),
|
||||||
Write(String, std::io::Error),
|
Write(String, std::io::Error),
|
||||||
@@ -23,9 +22,6 @@ impl fmt::Display for ProfileError {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
ProfileError::ParseFanLevel => write!(f, "Parse profile error"),
|
ProfileError::ParseFanLevel => write!(f, "Parse profile error"),
|
||||||
ProfileError::MissingProfile(profile) => {
|
|
||||||
write!(f, "Profile does not exist {}", profile)
|
|
||||||
}
|
|
||||||
ProfileError::Path(path, error) => write!(f, "Path {}: {}", path, error),
|
ProfileError::Path(path, error) => write!(f, "Path {}: {}", path, error),
|
||||||
ProfileError::Read(path, error) => write!(f, "Read {}: {}", path, error),
|
ProfileError::Read(path, error) => write!(f, "Read {}: {}", path, error),
|
||||||
ProfileError::Write(path, error) => write!(f, "Write {}: {}", path, error),
|
ProfileError::Write(path, error) => write!(f, "Write {}: {}", path, error),
|
||||||
|
|||||||
Reference in New Issue
Block a user