fix: udev-shim panic, sessiond duplicate, scheme Bad-fd handling
- udev-shim: replace .expect() with graceful errors (no more panic on Broken pipe) - P4-initfs: remove duplicate sessiond (conflicted with config) - accessibility/ime/keymapd: break instead of exit(1) on EBADF - P6 driver patches rebased - Docs: archive old reports, add implementation master plan
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
pub struct FanControl {
|
||||
pub fan_speed: u8,
|
||||
pub max_speed: u8,
|
||||
pub auto_mode: bool,
|
||||
pub trip_temp_c: f64,
|
||||
}
|
||||
|
||||
impl FanControl {
|
||||
pub fn new() -> Self { Self { fan_speed: 50, max_speed: 100, auto_mode: true, trip_temp_c: 60.0 } }
|
||||
|
||||
pub fn set_speed(&mut self, pct: u8) { self.fan_speed = pct.min(self.max_speed); self.auto_mode = false; }
|
||||
|
||||
pub fn update_from_temp(&mut self, temp_c: f64) {
|
||||
if !self.auto_mode { return; }
|
||||
self.fan_speed = if temp_c < 40.0 { 20 }
|
||||
else if temp_c < 50.0 { 40 }
|
||||
else if temp_c < 60.0 { 60 }
|
||||
else if temp_c < 70.0 { 80 }
|
||||
else { 100 };
|
||||
}
|
||||
|
||||
pub fn emergency_full(&mut self) { self.fan_speed = 100; self.auto_mode = false; }
|
||||
|
||||
pub fn write_acpi_fan(&self, fan_idx: u32) -> bool {
|
||||
let path = format!("/scheme/acpi/fan/{}/speed", fan_idx);
|
||||
fs::write(&path, format!("{}", self.fan_speed)).is_ok()
|
||||
}
|
||||
|
||||
pub fn read_acpi_fan_state(fan_idx: u32) -> Option<u8> {
|
||||
fs::read_to_string(format!("/scheme/acpi/fan/{}/state", fan_idx)).ok()
|
||||
.and_then(|s| s.trim().parse().ok())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user