mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Allow flexible profile cli input for LowPower
This commit is contained in:
@@ -275,11 +275,16 @@ impl std::str::FromStr for PlatformProfile {
|
|||||||
type Err = PlatformError;
|
type Err = PlatformError;
|
||||||
|
|
||||||
fn from_str(profile: &str) -> Result<Self> {
|
fn from_str(profile: &str) -> Result<Self> {
|
||||||
match profile.to_ascii_lowercase().trim() {
|
match profile
|
||||||
|
.to_ascii_lowercase()
|
||||||
|
.trim()
|
||||||
|
.replace(|c| !char::is_alphabetic(c), "")
|
||||||
|
.as_str()
|
||||||
|
{
|
||||||
"balanced" => Ok(PlatformProfile::Balanced),
|
"balanced" => Ok(PlatformProfile::Balanced),
|
||||||
"performance" => Ok(PlatformProfile::Performance),
|
"performance" => Ok(PlatformProfile::Performance),
|
||||||
"quiet" => Ok(PlatformProfile::Quiet),
|
"quiet" => Ok(PlatformProfile::Quiet),
|
||||||
"low-power" => Ok(PlatformProfile::LowPower),
|
"lowpower" => Ok(PlatformProfile::LowPower),
|
||||||
"custom" => Ok(PlatformProfile::Custom),
|
"custom" => Ok(PlatformProfile::Custom),
|
||||||
_ => Err(PlatformError::NotSupported),
|
_ => Err(PlatformError::NotSupported),
|
||||||
}
|
}
|
||||||
@@ -288,11 +293,16 @@ impl std::str::FromStr for PlatformProfile {
|
|||||||
|
|
||||||
impl From<&str> for PlatformProfile {
|
impl From<&str> for PlatformProfile {
|
||||||
fn from(profile: &str) -> Self {
|
fn from(profile: &str) -> Self {
|
||||||
match profile.to_ascii_lowercase().trim() {
|
match profile
|
||||||
|
.to_ascii_lowercase()
|
||||||
|
.trim()
|
||||||
|
.replace(|c| !char::is_alphabetic(c), "")
|
||||||
|
.as_str()
|
||||||
|
{
|
||||||
"balanced" => PlatformProfile::Balanced,
|
"balanced" => PlatformProfile::Balanced,
|
||||||
"performance" => PlatformProfile::Performance,
|
"performance" => PlatformProfile::Performance,
|
||||||
"quiet" => PlatformProfile::Quiet,
|
"quiet" => PlatformProfile::Quiet,
|
||||||
"low-power" => PlatformProfile::LowPower,
|
"lowpower" => PlatformProfile::LowPower,
|
||||||
"custom" => PlatformProfile::Custom,
|
"custom" => PlatformProfile::Custom,
|
||||||
_ => {
|
_ => {
|
||||||
warn!("{profile} is unknown, using ThrottlePolicy::Balanced");
|
warn!("{profile} is unknown, using ThrottlePolicy::Balanced");
|
||||||
|
|||||||
Reference in New Issue
Block a user