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

engine: try to handle systems with multiple batteries

This commit is contained in:
NotAShelf 2025-05-15 22:07:15 +03:00
parent 620dc48be0
commit 7c34ef5aa0
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
2 changed files with 3 additions and 3 deletions

View file

@ -73,7 +73,7 @@ pub struct SupportedBattery {
pub fn set_battery_charge_thresholds(start_threshold: u8, stop_threshold: u8) -> Result<()> {
// Validate thresholds using `BatteryChargeThresholds`
let thresholds = BatteryChargeThresholds::new(start_threshold, stop_threshold)
.map_err(|e| ControlError::InvalidValueError(e))?;
.map_err(ControlError::InvalidValueError)?;
let power_supply_path = Path::new("/sys/class/power_supply");
if !power_supply_path.exists() {

View file

@ -78,8 +78,8 @@ pub fn determine_and_apply_settings(
// No batteries means desktop/server, always on AC
true
} else {
// At least one battery exists, check if it's on AC
report.batteries.first().is_some_and(|b| b.ac_connected)
// Check if any battery reports AC connected
report.batteries.iter().any(|b| b.ac_connected)
};
if on_ac_power {