This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

machines.xerxes: fix fan spinning during s2idle suspend

+30 -2
+30 -2
machines/xerxes/gpd-fan.nix
··· 39 39 echo 1 > "$PWM_ENABLE" 40 40 41 41 cleanup() { 42 - echo "Restoring automatic fan control..." 43 - echo 0 > "$PWM_ENABLE" 2>/dev/null || true 42 + echo "Setting fan to 0..." 43 + echo 0 > "$PWM_FILE" 2>/dev/null || true 44 44 } 45 45 trap cleanup EXIT 46 46 ··· 70 70 # Disable the built-in fancontrol (it uses brittle hwmon numbers) 71 71 hardware.fancontrol.enable = false; 72 72 73 + # Stop fan service and set PWM to 0 before s2idle, restart after resume 74 + environment.etc."systemd/system-sleep/gpd-fan".source = pkgs.writeShellScript "gpd-fan-sleep" '' 75 + find_hwmon() { 76 + for hwmon in /sys/class/hwmon/hwmon*; do 77 + if [ -f "$hwmon/name" ] && [ "$(cat "$hwmon/name")" = "$1" ]; then 78 + echo "$hwmon" 79 + return 0 80 + fi 81 + done 82 + return 1 83 + } 84 + case "$1" in 85 + pre) 86 + # Stop the fan service first so it can't overwrite our PWM 0 87 + systemctl stop gpd-fan-control.service 88 + FAN=$(find_hwmon gpdfan) 89 + if [ -n "$FAN" ]; then 90 + echo 1 > "$FAN/pwm1_enable" 91 + echo 0 > "$FAN/pwm1" 92 + fi 93 + ;; 94 + post) 95 + systemctl start gpd-fan-control.service 96 + ;; 97 + esac 98 + ''; 99 + 73 100 systemd.services.gpd-fan-control = { 74 101 description = "GPD Fan Control (dynamic hwmon discovery)"; 75 102 wantedBy = [ "multi-user.target" ]; ··· 80 107 RestartSec = 5; 81 108 }; 82 109 }; 110 + 83 111 }