-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsi_fan_control.sh
More file actions
executable file
·87 lines (71 loc) · 2.01 KB
/
msi_fan_control.sh
File metadata and controls
executable file
·87 lines (71 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# MSI Fan Monitor and Cooler Boost Control
# Tested on GL65 Leopard 9SCXK (firmware 16U8EMS2.100)
EC_DEVICE="/dev/ec0"
# Register addresses (verified for 16U8 firmware)
REG_CPU_TEMP=104 # 0x68
REG_CPU_FAN=112 # 0x70
REG_GPU_TEMP=128 # 0x80
REG_GPU_FAN=136 # 0x88
REG_COOLER_BOOST=152 # 0x98
check_root() {
[ "$EUID" -ne 0 ] && { echo "Error: Run as root"; exit 1; }
}
check_ec() {
[ ! -c "$EC_DEVICE" ] && { echo "Error: $EC_DEVICE not found"; exit 1; }
}
ec_read() {
dd if="$EC_DEVICE" bs=1 count=1 skip="$1" 2>/dev/null | od -An -tu1 | tr -d ' '
}
get_status() {
local cpu_temp=$(ec_read $REG_CPU_TEMP)
local cpu_fan=$(ec_read $REG_CPU_FAN)
local gpu_temp=$(ec_read $REG_GPU_TEMP)
local gpu_fan=$(ec_read $REG_GPU_FAN)
local boost=$(ec_read $REG_COOLER_BOOST)
echo "MSI Fan Status"
echo "=============="
echo "CPU: ${cpu_temp}C @ ${cpu_fan}%"
echo "GPU: ${gpu_temp}C @ ${gpu_fan}%"
[ "$boost" -ge 128 ] && echo "Cooler Boost: ON" || echo "Cooler Boost: OFF"
}
boost_on() {
echo -ne "\x80" | dd of="$EC_DEVICE" bs=1 count=1 seek=$REG_COOLER_BOOST 2>/dev/null
sleep 0.5
[ "$(ec_read $REG_COOLER_BOOST)" -ge 128 ] && echo "Cooler Boost: ON" || echo "Failed"
}
boost_off() {
echo -ne "\x00" | dd of="$EC_DEVICE" bs=1 count=1 seek=$REG_COOLER_BOOST 2>/dev/null
sleep 0.5
[ "$(ec_read $REG_COOLER_BOOST)" -lt 128 ] && echo "Cooler Boost: OFF" || echo "Failed"
}
monitor() {
local interval=${1:-2}
while true; do
clear
get_status
sleep $interval
done
}
usage() {
cat << EOF
Usage: $0 <command>
Commands:
status Show temps and fan speeds
monitor Live monitoring
boost-on Enable Cooler Boost
boost-off Disable Cooler Boost
Examples:
sudo $0 status
sudo $0 boost-on
EOF
}
check_root
check_ec
case "$1" in
status) get_status ;;
monitor) monitor "$2" ;;
boost-on|on) boost_on ;;
boost-off|off) boost_off ;;
*) usage; exit 1 ;;
esac