wiiznokes / fan-control

Control your fans with different behaviors
GNU General Public License v3.0
153 stars 11 forks source link

Different hwmon required #117

Open Gnarflord opened 5 months ago

Gnarflord commented 5 months ago

I'm running fancontrol-gui via the snap package manager and thus need udev rules. The default udev rules from this github assume hwmon7 to be the correct one for PWM control:

SUBSYSTEM=="hwmon", KERNEL=="hwmon7", RUN+="/bin/sh -c '/bin/chmod a+w /sys%p/pwm*'"

My system doesn't even have a folder for hwmon7:

❯ ls /sys/class/hwmon
hwmon0  hwmon1  hwmon2  hwmon3  hwmon4

So I looked into the directories and hwmon1 had 1 PWM controllers and hwmon4 had 7 PWM controllers. These are the controllers from my graphics card (nvidia, so noveau driver) and my motherboard:

❯ /usr/bin/cat /sys/class/hwmon/hwmon1/name
nouveau

❯ /usr/bin/cat /sys/class/hwmon/hwmon4/name
nct6798

Only after adding a line for hwmon1 and hwmon4 in the udev file was I able to control my fans.

I propose two solutions:

or

Please note that hwmon numbers will also change upon changing hardware configuration. So after swapping out a graphics card or the motherboard all numbers will be mixed up again (which will also mess with the fancontrol config file...)

wiiznokes commented 5 months ago

Thanks for bringing that up. Tbh, it seemed odd to me that only hwon7 was useful.

I'm running fancontrol-gui via the snap package manager

Didn't known that was possible. Are you planning to make a snap package or it's just something personal ?

# XXX: Only hwmon7 because it failed on all other number on machine
SUBSYSTEM=="hwmon", KERNEL=="hwmon7", RUN+="/bin/sh -c '/bin/chmod a+w /sys%p/pwm*'"

As the comment say, i specified the 7 because the chmod command was runned for every KERNEL, thus causing errors. It just not nice for logs, but i guess we could wildcard the kernel number (KERNEL=="hwmon[0-99]") or just remove it, and discard any error (command || true).

Please note that hwmon numbers will also change upon changing hardware configuration. So after swapping out a graphics card or the motherboard all numbers will be mixed up again (which will also mess with the fancontrol config file...)

I don't see it as an issue, because it will not make the app crash. The config is sanitized at runtime.

We might be able to play with OWNER, GROUP, MODE and TAG+="uaccess" instead of relying on hacky chmod command (doc).