You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(fan): detect missing fan_control=1 instead of blaming permissions (#23)
Likely the most common reason fan control does not work, and the app
currently sends users somewhere that cannot possibly fix it.
thinkpad_acpi's fan_set_level() opens with:
if (!fan_control_allowed) return -EPERM;
and the parameter is module_param_named(fan_control, ..., 0444). Mode
0444 means it is not writable at runtime -- it needs a modprobe.d entry
plus a module reload or reboot. Nothing in this repo ever set it, so on
a stock ThinkPad every write fails and set_fan_speed reported
'Permission denied. Click Grant Permissions', which can never help
because the obstacle is the kernel module, not polkit.
Detection is read-only and needs no privileges. The driver zeroes
fan_control_commands when the parameter is off, and fan_read() only
emits the 'commands:' lines when it is set, so their absence means
writes will fail. Verified against a machine with fan_control=1 set:
three commands: lines present.
Adds:
get_fan_capability() -- Ready / NeedsModuleParam / NoThinkpadFan,
with a message that names the real obstacle
enable_fan_control() -- writes the modprobe.d entry and attempts a
reload, re-probing afterwards rather than
assuming it worked. A busy module cannot be
reloaded, so that case reports 'reboot to
activate' instead of claiming success.
set_fan_speed now checks this first and returns the accurate message.
The three-state readiness matters: 'could not check' must never render
as 'not supported'.
(FanReadiness::Ready,"Fan control is available.".to_string())
157
+
}
158
+
Ok(_)if modprobe_conf_present => (
159
+
FanReadiness::NeedsModuleParam,
160
+
"Fan control is configured but not active yet. Reboot, or reload the thinkpad_acpi module.".to_string(),
161
+
),
162
+
Ok(_) => (
163
+
FanReadiness::NeedsModuleParam,
164
+
"The thinkpad_acpi module was loaded without fan_control=1, so it will refuse fan changes. This is a kernel module setting, not a permissions problem.".to_string(),
165
+
),
166
+
};
167
+
168
+
ApiResponse{
169
+
success:true,
170
+
data:Some(FanCapability{
171
+
readiness,
172
+
modprobe_conf_present,
173
+
message,
174
+
}),
175
+
error:None,
176
+
}
177
+
}
178
+
179
+
/// Write the modprobe config and try to reload the module.
// Check the module parameter before trying anything. If fan_control=1 is
370
+
// missing the kernel returns -EPERM no matter who we are, and telling the
371
+
// user to grant permissions sends them somewhere that cannot help.
372
+
ifletOk(content) = fs::read_to_string(PROC_FAN){
373
+
if !fan_control_is_enabled(&content){
374
+
returnApiResponse{
375
+
success:false,
376
+
data:None,
377
+
error:Some(
378
+
"The thinkpad_acpi module was loaded without fan_control=1, so the kernel will refuse fan changes. Enable it from the Fan Control page — this is a module setting, not a permissions problem.".to_string(),
0 commit comments