1
Fork 0
mirror of https://github.com/RGBCube/superfreq synced 2025-07-27 17:07:44 +00:00

system: check for chassis type 31 and move power saving check below

Co-Authored-By: flashrun24 <flashrun42@gmail.com>
This commit is contained in:
RGBCube 2025-05-27 21:24:06 +03:00
parent a343e38d95
commit 2812baa77b
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M

View file

@ -52,16 +52,18 @@ impl System {
if let Some(chassis_type) = if let Some(chassis_type) =
fs::read("/sys/class/dmi/id/chassis_type").context("failed to read chassis type")? fs::read("/sys/class/dmi/id/chassis_type").context("failed to read chassis type")?
{ {
// 3=Desktop, 4=Low Profile Desktop, 5=Pizza Box, 6=Mini Tower // 3=Desktop, 4=Low Profile Desktop, 5=Pizza Box, 6=Mini Tower,
// 7=Tower, 8=Portable, 9=Laptop, 10=Notebook, 11=Hand Held, 13=All In One // 7=Tower, 8=Portable, 9=Laptop, 10=Notebook, 11=Hand Held, 13=All In One,
// 14=Sub Notebook, 15=Space-saving, 16=Lunch Box, 17=Main Server Chassis // 14=Sub Notebook, 15=Space-saving, 16=Lunch Box, 17=Main Server Chassis,
// 31=Convertible Laptop
match chassis_type.trim() { match chassis_type.trim() {
// Desktop form factors. // Desktop form factors.
"3" | "4" | "5" | "6" | "7" | "15" | "16" | "17" => { "3" | "4" | "5" | "6" | "7" | "15" | "16" | "17" => {
return Ok(true); return Ok(true);
} }
// Laptop form factors. // Laptop form factors.
"9" | "10" | "14" => { "9" | "10" | "14" | "31" => {
return Ok(false); return Ok(false);
} }
@ -70,14 +72,6 @@ impl System {
} }
} }
// Check CPU power policies, desktops often don't have these
let power_saving_exists = fs::exists("/sys/module/intel_pstate/parameters/no_hwp")
|| fs::exists("/sys/devices/system/cpu/cpufreq/conservative");
if !power_saving_exists {
return Ok(true); // Likely a desktop.
}
// Check battery-specific ACPI paths that laptops typically have // Check battery-specific ACPI paths that laptops typically have
let laptop_acpi_paths = [ let laptop_acpi_paths = [
"/sys/class/power_supply/BAT0", "/sys/class/power_supply/BAT0",
@ -91,6 +85,14 @@ impl System {
} }
} }
// Check CPU power policies, desktops often don't have these
let power_saving_exists = fs::exists("/sys/module/intel_pstate/parameters/no_hwp")
|| fs::exists("/sys/devices/system/cpu/cpufreq/conservative");
if !power_saving_exists {
return Ok(true); // Likely a desktop.
}
// Default to assuming desktop if we can't determine. // Default to assuming desktop if we can't determine.
Ok(true) Ok(true)
} }