diff --git a/resource/linux/60-fan-control.rules b/resource/linux/60-fan-control.rules index 15b7adff..72071027 100644 --- a/resource/linux/60-fan-control.rules +++ b/resource/linux/60-fan-control.rules @@ -1,2 +1,7 @@ -KERNEL=="hwmon7", SUBSYSTEM=="hwmon", TAG+="uaccess" \ No newline at end of file +# 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*'" + + +# LOGS VERSION +# SUBSYSTEM=="hwmon", KERNEL=="hwmon7", RUN+="/bin/sh -c '/bin/chmod -v a+w /sys%p/pwm* > /tmp/fan-control-udev.txt 2>&1'" \ No newline at end of file diff --git a/resource/linux/install_udev_rules.sh b/resource/linux/install_udev_rules.sh deleted file mode 100755 index a3f821a7..00000000 --- a/resource/linux/install_udev_rules.sh +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/bash - -STEAMOS=0 -STEAMOS_READONLY=0 - -# Test for SteamOS and disable readonly mode if we're running on it -if command -v steamos-readonly >& /dev/null -then - # Test if SteamOS readonly mode is enabled - if sudo steamos-readonly status | grep 'enabled' - then - echo "steamos readonly mode is true" - STEAMOS_READONLY=1 - fi - - STEAMOS=1 - sudo steamos-readonly disable -fi - -# Download udev rules file -#wget https://raw.githubusercontent.com/wiiznokes/fan-control/flatpak/resource/linux/60-fan-control.rules - -# Move udev rules file to udev rules directory -sudo mv 60-fan-control.rules /usr/lib/udev/rules.d -#sudo install -m644 90-fan-control.rules /usr/lib/udev/rules.d - -# Reload the rules -sudo udevadm control --reload-rules && sudo udevadm trigger - - -if [ "$STEAMOS" = 1 ] ; then - if [ "$STEAMOS_READONLY" = 1 ] ; then - sudo steamos-readonly enable - fi -fi diff --git a/resource/linux/rules-note.md b/resource/linux/rules-note.md new file mode 100644 index 00000000..4a80d2c2 --- /dev/null +++ b/resource/linux/rules-note.md @@ -0,0 +1,60 @@ +# Some notes on udev rules + +### see some logs: +```sh +journalctl -f +``` + +### reload +```sh +sudo udevadm control --reload-rules && sudo udevadm trigger +``` + +### show info about triggering and devices (test the hwmon7 device ?) +```sh +sudo udevadm test /sys/class/hwmon/hwmon7 +``` + +### show info +```sh +udevadm monitor -u | grep hwmon +``` + +## Other +```sh +ll /sys/class/hwmon/hwmon7/pwm* +sudo /bin/chmod a-w /sys/class/hwmon/hwmon7/pwm* +cat /tmp/fan-control-udev.txt +wget https://openrgb.org/releases/release_0.9/60-openrgb.rules +``` + +- `TAG+="uaccess"` is not enough on my PC. +- `chmod g+w` is not enough on my PC. +- only the hwmon7 seems to be relevant on my PC. +- hwmon7 is the kernel name. It can be refered as %k in the rules file. +- %p is the device path. For example, the device path of hwmon7 (`/sys/class/hwmon/hwmon7`) is `/sys/devices/platform/nct6775.656/hwmon/hwmon7` + + + +`ACTION=="add"`: the rule will only be triggered when a device is added to the system +`KERNEL=="hwmon[0-99]"`: match any version of hwmon kernel name + +### Export log to a file in a RUN clause +``` +RUN+="/bin/sh -c '{COMMAND} > /tmp/fan-control-udev.txt 2>&1'" +``` + +`chmod a+w /sys%p/pwm*`: The * will only make sense in a shell program, that why we spawn /bin/sh before + +### Attempt to filter pwmX and pwmX_enable + +This two files are the only one that the app use. +The regex and command work in a terminal on my machine, but don't work inside a RUN clause. +``` +SUBSYSTEM=="hwmon", KERNEL=="hwmon7", RUN+="/bin/sh -c '/bin/find /sys%p -type f -regex '/sys%p/pwm[0-99]\(_enable\)?' -exec /bin/chmod a+w {} \; > /tmp/fan-control-udev.txt 2>&1'" +``` + + +### path for rules: +- /etc/udev/rules.d/60-fan-control.rules +- /usr/lib/udev/rules.d/60-fan-control.rules \ No newline at end of file diff --git a/resource/linux/rules.txt b/resource/linux/rules.txt deleted file mode 100644 index 4d4ff4fc..00000000 --- a/resource/linux/rules.txt +++ /dev/null @@ -1,47 +0,0 @@ - -# The kernel name is assigned to devices by the kernel. It is unique. - -# uaccess add user access to the device. It will be able to interact with -# the way the device was configured - -KERNEL=="i2c-[0-99]*", TAG+="uaccess" - - - -# Action add: this rule will be triggered when a device is added to the system -# SUBSYSTEM=="platform": In Linux, the "platform" subsystem typically represents -# hardware devices integrated into the system's motherboard or platform. -# RUN ...: add write permission to all user to the file. %k get replaced by the kernel name (so faustus) - - -ACTION=="add", SUBSYSTEM=="platform", KERNEL=="faustus", RUN+="/bin/chmod a+w /sys/bus/platform/devices/%k/kbbl/kbbl_speed" - - - - - - - -SUBSYSTEMS=="usb|hidraw", ATTRS{idVendor}=="3061", ATTRS{idProduct}=="4772", TAG+="uaccess", TAG+="GaiZhongGai_20_PRO" - - - -use udevadm monitor -u | grep hwmon to see what rules get triggered - - - - -We need to check if uaccess is enough or we need to change ownership -Is it always in hwmon7 ? - - -https://github.com/lm-sensors/lm-sensors/issues/426 - -find . -name "pwm2*" -exec sudo chmod a+w {} \; - -# KERNEL=="hwmon[0-99]*" - -# RUN+="/bin/chmod -R a+w /sys/class/hwmon/hwmon7" - - -https://gitlab.com/CalcProgrammer1/OpenRGB/ \ No newline at end of file