Skip to content

Commit a37f886

Browse files
fans
1 parent 341cc84 commit a37f886

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

desktop/l/corsair-fan-control.nix

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
# Uses liquidctl to control the fan speed.
66
#
77

8+
# sudo liquidctl status --match corsair
9+
810
{ config, lib, pkgs, ... }:
911

1012
let
1113
# Configuration - modify these values for your setup
1214
fanNumber = "fan1"; # Change this to control different fans (fan1, fan2, fan3, etc.)
13-
fanSpeed = 100; # Change this to desired fan speed (0-100)
15+
fanSpeed = 50; # Change this to desired fan speed (0-100)
1416

15-
# Script to set fan speed using liquidctl
17+
# Script to set fan speed using liquidctl
1618
corsairFanControlScript = pkgs.writeShellScript "corsair-fan-control" ''
1719
#!/bin/sh
1820
set -eu
@@ -22,15 +24,8 @@ let
2224
2325
echo "Setting Corsair Commander ${fanNumber} speed to ${toString fanSpeed}%"
2426
25-
# Check if liquidctl is available
26-
if ! command -v liquidctl >/dev/null 2>&1; then
27-
echo "Error: liquidctl not found. Please install it first."
28-
exit 1
29-
fi
30-
31-
# Set the fan speed
32-
# Note: fanSpeed is interpolated by Nix, so we use toString to convert the integer to string
33-
if liquidctl --match corsair set "$FAN_NUMBER" speed "$FAN_SPEED"; then
27+
# Set the fan speed using the full path to liquidctl
28+
if ${pkgs.liquidctl}/bin/liquidctl --match corsair set "$FAN_NUMBER" speed "$FAN_SPEED"; then
3429
echo "Fan speed set successfully to ${toString fanSpeed}%"
3530
exit 0
3631
else

desktop/l/gpu-fan-control.nix

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
# Configure the GPU bus address and desired fan speed below.
66
#
77

8+
# [nix-shell:~/nixos/desktop/l]$ rocm-smi
9+
10+
11+
# =========================================== ROCm System Management Interface ===========================================
12+
# ===================================================== Concise Info =====================================================
13+
# Device Node IDs Temp Power Partitions SCLK MCLK Fan Perf PwrCap VRAM% GPU%
14+
# (DID, GUID) (Edge) (Socket) (Mem, Compute, ID)
15+
# ========================================================================================================================
16+
# 0 2 0x66a1, 33678 35.0°C 19.0W N/A, N/A, 0 938Mhz 350Mhz 100.0% auto 225.0W 0% 0%
17+
# 1 1 0x7312, 11012 45.0°C 33.0W N/A, N/A, 0 800Mhz 900Mhz 49.41% auto 140.0W 22% 2%
18+
# ========================================================================================================================
19+
# ================================================= End of ROCm SMI Log ==================================================
20+
821
{ config, lib, pkgs, ... }:
922

1023
let
@@ -15,7 +28,7 @@ let
1528
#44:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Vega 20 [Radeon Pro VII/Radeon Instinct MI50 32GB]
1629
#63:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 [Radeon Pro W5700]
1730

18-
fanSpeedPercent = 50; # Change this to desired fan speed (0-100)
31+
fanSpeedPercent = 40; # Change this to desired fan speed (0-100)
1932

2033
# Calculate the actual PWM value based on percentage
2134
fanSpeedPWM = builtins.toString (fanSpeedPercent * 255 / 100);
@@ -50,8 +63,8 @@ let
5063
echo "Max PWM: $max_pwm"
5164
5265
# Calculate actual PWM value based on percentage
53-
# Note: fanSpeedPercent is interpolated by Nix as a literal number, so we use it directly in Bash arithmetic
54-
actual_pwm=$(( max_pwm * ${fanSpeedPercent} / 100 ))
66+
# Note: fanSpeedPercent is interpolated by Nix, so we use toString to convert the integer to string
67+
actual_pwm=$(( max_pwm * ${toString fanSpeedPercent} / 100 ))
5568
echo "Setting PWM to $actual_pwm"
5669
echo "$actual_pwm" > "$hwmon/pwm1"
5770

0 commit comments

Comments
 (0)