diff --git a/config.toml b/config.toml index 293c9e8..421aa62 100644 --- a/config.toml +++ b/config.toml @@ -5,28 +5,27 @@ # Emergency thermal protection (highest priority). [[rule]] +if = { value = "$cpu-temperature", is-more-than = 85.0 } +priority = 100 + cpu.energy-performance-preference = "power" cpu.frequency-mhz-maximum = 2000 cpu.governor = "powersave" cpu.turbo = false -if = { value = "$cpu-temperature", is-more-than = 85.0 } -priority = 100 # Critical battery preservation. [[rule]] +if.all = [ "?discharging", { value = "%power-supply-charge", is-less-than = 0.3 } ] +priority = 90 + cpu.energy-performance-preference = "power" -cpu.frequency-mhz-maximum = 800 # More aggressive below critical threshold. +cpu.frequency-mhz-maximum = 800 # More aggressive below critical threshold. cpu.governor = "powersave" cpu.turbo = false -if.all = [ "?discharging", { value = "%power-supply-charge", is-less-than = 0.3 } ] power.platform-profile = "low-power" -priority = 90 # High performance mode for sustained high load. [[rule]] -cpu.energy-performance-preference = "performance" -cpu.governor = "performance" -cpu.turbo = true if.all = [ { value = "%cpu-usage", is-more-than = 0.8 }, { value = "$cpu-idle-seconds", is-less-than = 30.0 }, @@ -34,12 +33,12 @@ if.all = [ ] priority = 80 +cpu.energy-performance-preference = "performance" +cpu.governor = "performance" +cpu.turbo = true + # Performance mode when not discharging. [[rule]] -cpu.energy-performance-bias = "balance_performance" -cpu.energy-performance-preference = "performance" -cpu.governor = "performance" -cpu.turbo = true if.all = [ { not = "?discharging" }, { value = "%cpu-usage", is-more-than = 0.1 }, @@ -47,56 +46,66 @@ if.all = [ ] priority = 70 +cpu.energy-performance-bias = "balance_performance" +cpu.energy-performance-preference = "performance" +cpu.governor = "performance" +cpu.turbo = true + # Moderate performance for medium load. [[rule]] -cpu.energy-performance-preference = "balance_performance" -cpu.governor = "schedutil" if.all = [ { value = "%cpu-usage", is-more-than = 0.4 }, { value = "%cpu-usage", is-less-than = 0.8 }, ] priority = 60 +cpu.energy-performance-preference = "balance_performance" +cpu.governor = "schedutil" + # Power saving during low activity. [[rule]] -cpu.energy-performance-preference = "power" -cpu.governor = "powersave" -cpu.turbo = false if.all = [ { value = "%cpu-usage", is-less-than = 0.2 }, { value = "$cpu-idle-seconds", is-more-than = 60.0 }, ] priority = 50 +cpu.energy-performance-preference = "power" +cpu.governor = "powersave" +cpu.turbo = false + # Extended idle power optimization. [[rule]] +if = { value = "$cpu-idle-seconds", is-more-than = 300.0 } +priority = 40 + cpu.energy-performance-preference = "power" cpu.frequency-mhz-maximum = 1600 cpu.governor = "powersave" cpu.turbo = false -if = { value = "$cpu-idle-seconds", is-more-than = 300.0 } -priority = 40 # Battery conservation when discharging. [[rule]] +if.all = [ "?discharging", { value = "%power-supply-charge", is-less-than = 0.5 } ] +priority = 30 + cpu.energy-performance-preference = "power" cpu.frequency-mhz-maximum = 2000 cpu.governor = "powersave" cpu.turbo = false -if.all = [ "?discharging", { value = "%power-supply-charge", is-less-than = 0.5 } ] power.platform-profile = "low-power" -priority = 30 # General battery mode. [[rule]] +if = "?discharging" +priority = 20 + cpu.energy-performance-bias = "balance_power" cpu.energy-performance-preference = "power" cpu.frequency-mhz-maximum = 1800 cpu.frequency-mhz-minimum = 200 cpu.governor = "powersave" cpu.turbo = false -if = "?discharging" -priority = 20 # Balanced performance for general use. Default fallback rule. [[rule]] diff --git a/src/power_supply.rs b/src/power_supply.rs index 3bd03f2..fd11712 100644 --- a/src/power_supply.rs +++ b/src/power_supply.rs @@ -227,10 +227,13 @@ impl PowerSupply { } } // Check for model name that indicates a peripheral - if let Some(model) = fs::read(self.path.join("model_name")) + if let Some(model_name) = fs::read(self.path.join("model_name")) .with_context(|| format!("failed to read the model name of {self}"))? { - if model.contains("bluetooth") || model.contains("wireless") { + let model_name_lower = model_name.to_lowercase(); + if model_name_lower.contains("bluetooth") + || model_name_lower.contains("wireless") + { break 'is_from_peripheral true; } } diff --git a/src/system.rs b/src/system.rs index fccf624..19bcafd 100644 --- a/src/system.rs +++ b/src/system.rs @@ -295,8 +295,8 @@ impl System { "stripped content is a valid number, taking it as the core number" ); log::debug!( - "it is fine if this number doesn't seem accurate due to CPU binning, see a more detailed explanation at: https://rgbcu.be/blog/why-cores" - ); + "it is fine if this number doesn't seem accurate due to CPU binning, see a more detailed explanation at: https://rgbcu.be/blog/why-cores" + ); let Some(temperature_mc) = fs::read_n::(&input_path).with_context(|| {