dsh-qqbot-muu 0.1.15 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +168 -85
- package/client/qqbot-settings.js +13401 -12024
- package/config/modules.json +212 -0
- package/dist/channel-tools.js +21 -10
- package/dist/config.d.ts +14 -0
- package/dist/config.js +573 -449
- package/dist/features/contextless-store.js +247 -247
- package/dist/features/contextless-trim.js +455 -34
- package/dist/features/four-source.js +338 -336
- package/dist/features/group-join-request.js +289 -287
- package/dist/features/local-models.js +1494 -0
- package/dist/features/rotate-summarizer.js +438 -0
- package/dist/features/scenario-detect.js +321 -0
- package/dist/features/scheduler.js +8 -1
- package/dist/features/session-rotate.js +499 -0
- package/dist/features/session-title.js +199 -0
- package/dist/features/style-layer.js +501 -0
- package/dist/features/thinking-log.js +71 -69
- package/dist/gateway/bootstrap.js +1704 -1388
- package/dist/gateway/data-root.js +77 -3
- package/dist/gateway/middleware-setup.js +6 -3
- package/dist/index.js +4 -2
- package/dist/model/settings-reader.js +193 -102
- package/dist/session/session-manager.js +1730 -1587
- package/dist/shared/paths.js +128 -0
- package/dist/shared/settings-io.js +79 -0
- package/dist/transport/inbound.js +20 -1
- package/dist/transport/outbound.js +56 -4
- package/docs/RELEASE_CHECKLIST.md +24 -2
- package/dshqqbot/.qqbot-extensions/hooks/interview-panel.mjs +41 -1
- package/dshqqbot/.qqbot-extensions/inbound/00-vision.mjs +111 -0
- package/dshqqbot/.qqbot-extensions/inbound/aa-memory-recall.mjs +802 -689
- package/dshqqbot/.qqbot-extensions/inbound/ac-image-see.mjs +1 -1
- package/dshqqbot/.qqbot-extensions/inbound/az-feedback.mjs +113 -115
- package/dshqqbot/.qqbot-extensions/inbound/local-answer.mjs +689 -568
- package/dshqqbot/.qqbot-extensions/lib/.pet-form.json +1 -1
- package/dshqqbot/.qqbot-extensions/lib/draw-core.mjs +238 -7
- package/dshqqbot/.qqbot-extensions/lib/local-llm.mjs +455 -394
- package/dshqqbot/.qqbot-extensions/lib/memory-agent.mjs +930 -928
- package/dshqqbot/.qqbot-extensions/lib/memory-core.mjs +537 -537
- package/dshqqbot/.qqbot-extensions/lib/memory-db.mjs +2476 -2245
- package/dshqqbot/.qqbot-extensions/lib/memory-hippo.mjs +18 -0
- package/dshqqbot/.qqbot-extensions/lib/memory.mjs +191 -186
- package/dshqqbot/.qqbot-extensions/lib/plugin-dir.mjs +14 -4
- package/dshqqbot/.qqbot-extensions/lib/scope-util.mjs +84 -0
- package/dshqqbot/.qqbot-extensions/lib/vision.mjs +1 -1
- package/dshqqbot/.qqbot-extensions/outbound/aa-sanitize.mjs +158 -154
- package/dshqqbot/.qqbot-extensions/outbound/ac-media-fix.mjs +5 -1
- package/dshqqbot/.qqbot-extensions/outbound/memory-agent.mjs +121 -130
- package/dshqqbot/.qqbot-extensions/outbound/split-reply.mjs +18 -2
- package/dshqqbot/.qqbot-extensions/outbound/turn-memory.mjs +92 -101
- package/dshqqbot/.qqbot-extensions/tools/draw.mjs +22 -1
- package/dshqqbot/.qqbot-extensions/tools/memory.mjs +178 -120
- package/dshqqbot/.qqbot-extensions/tools/pet_card.mjs +3 -2
- package/dshqqbot/.qqbot-extensions/tools/storyboard.mjs +3 -1
- package/dshqqbot/.qqbot-extensions/vendor/abogus/test-abogus.mjs +128 -126
- package/package.json +119 -111
- package/scripts/__pycache__/fan-mode.cpython-311.pyc +0 -0
- package/scripts/__pycache__/memory-audit.cpython-311.pyc +0 -0
- package/scripts/__pycache__/qq-ip-sync.cpython-311.pyc +0 -0
- package/scripts/__pycache__/qq-whitelist.cpython-311.pyc +0 -0
- package/scripts/_add_maintenance_cfg.py +20 -0
- package/scripts/_bench_keeplease.sh +10 -0
- package/scripts/_dbg_purge.py +15 -0
- package/scripts/_elev.sh +6 -0
- package/scripts/_fix_all_admin.cmd +16 -0
- package/scripts/_livecheck-image.mjs +33 -0
- package/scripts/_livecheck-llm.mjs +34 -0
- package/scripts/_livecheck-tts.mjs +37 -0
- package/scripts/_patch_curve.py +88 -0
- package/scripts/_patch_fan_thermal.py +24 -0
- package/scripts/_tag_tmp.py +13 -0
- package/scripts/adb-broker-client.mjs +87 -0
- package/scripts/adb-broker.mjs +205 -0
- package/scripts/ai-mode.cmd +6 -0
- package/scripts/ai-mode.py +387 -0
- package/scripts/ai-toolkit.py +607 -0
- package/scripts/apply-fan-gpu45.py +51 -0
- package/scripts/bench-fans.py +515 -0
- package/scripts/bench-load-direct.py +63 -0
- package/scripts/boot-tasks-hidden.vbs +20 -0
- package/scripts/boot-tasks.cmd +277 -0
- package/scripts/chat-archive/__pycache__/build-sft-v4.cpython-311.pyc +0 -0
- package/scripts/chat-archive/__pycache__/build-sft.cpython-311.pyc +0 -0
- package/scripts/chat-archive/build-sft-v4.py +566 -0
- package/scripts/chat-archive/build-sft.py +390 -0
- package/scripts/chat-archive/eval-sft.py +155 -0
- package/scripts/chat-archive/extract-memory.py +143 -0
- package/scripts/chat-archive/inventory.py +182 -0
- package/scripts/chat-archive/merge-sft.py +114 -0
- package/scripts/chat-archive/qce-pull.py +217 -0
- package/scripts/chat-archive/qqheader.py +110 -0
- package/scripts/chat-archive/qqkey2.py +113 -0
- package/scripts/chat-archive/qqprobe.py +153 -0
- package/scripts/chat-archive/screen-collect.py +163 -0
- package/scripts/chat-archive/sqlcipher_probe.py +444 -0
- package/scripts/comfy_gen.py +209 -0
- package/scripts/compose-video.py +168 -0
- package/scripts/dl_models.py +45 -0
- package/scripts/draw-now.cmd +18 -0
- package/scripts/dsh-instance-guard.mjs +20 -2
- package/scripts/elev-extra.cmd +25 -0
- package/scripts/episode.py +529 -0
- package/scripts/fan-curve.py +218 -0
- package/scripts/fan-guard.cmd +8 -0
- package/scripts/fan-mode.py +380 -0
- package/scripts/fan_manual_safe.py +33 -0
- package/scripts/fan_restore_manual.py +46 -0
- package/scripts/fc_curves.py +359 -0
- package/scripts/fix-fan-and-timers.cmd +39 -0
- package/scripts/fix_admin_all.py +94 -0
- package/scripts/flows.mjs +224 -0
- package/scripts/gateway.cmd +126 -0
- package/scripts/gen-image.py +420 -0
- package/scripts/gen-video.py +186 -0
- package/scripts/git-askpass.cmd +2 -2
- package/scripts/gpu-mode.py +195 -0
- package/scripts/hw-profile.py +175 -0
- package/scripts/install-schedule.cmd +37 -0
- package/scripts/install-watch.cmd +29 -0
- package/scripts/matte-cutout.py +106 -0
- package/scripts/media-enhance.py +402 -0
- package/scripts/memory-audit.py +581 -0
- package/scripts/migrate-scope.mjs +140 -139
- package/scripts/model-registry.py +519 -0
- package/scripts/openid-audit.mjs +219 -0
- package/scripts/pull-gguf.py +127 -0
- package/scripts/purge-standby.py +151 -0
- package/scripts/qq-connect-login.py +133 -0
- package/scripts/qq-ip-sync-hidden.vbs +5 -0
- package/scripts/qq-ip-sync.py +300 -0
- package/scripts/qq-login-once.cmd +20 -0
- package/scripts/qq-login-qr.py +72 -0
- package/scripts/qq-whitelist-fix.cmd +27 -0
- package/scripts/qq-whitelist-login.cmd +26 -0
- package/scripts/qq-whitelist.cmd +12 -0
- package/scripts/qq-whitelist.py +1452 -0
- package/scripts/quality-compare.py +134 -0
- package/scripts/release-all.mjs +636 -430
- package/scripts/release-check.mjs +244 -226
- package/scripts/resume-coder.cmd +38 -0
- package/scripts/secure-room/index.html +334 -0
- package/scripts/secure-room/server.py +582 -0
- package/scripts/security-check.mjs +164 -0
- package/scripts/selftest-local-llm.mjs +20 -0
- package/scripts/selftest-local-models.mjs +754 -0
- package/scripts/selftest-rotate-style.mjs +308 -0
- package/scripts/shutdown-s5-optional.cmd +21 -0
- package/scripts/sleep-2325.cmd +75 -0
- package/scripts/start-comfyui.cmd +5 -0
- package/scripts/start-strata.cmd +17 -0
- package/scripts/start-strata.vbs +11 -0
- package/scripts/start-watch-hidden.vbs +3 -0
- package/scripts/stickers/auto-tag.mjs +161 -0
- package/scripts/storage.mjs +236 -0
- package/scripts/sync-plugin-copies.mjs +98 -23
- package/scripts/tests/test-qq-whitelist.py +192 -0
- package/scripts/train/__pycache__/train-lora.cpython-311.pyc +0 -0
- package/scripts/train/gguf-quantize.py +92 -0
- package/scripts/train/gguf-to-hf.py +112 -0
- package/scripts/train/merge-lora.py +51 -0
- package/scripts/train/probe-mirrors.sh +12 -0
- package/scripts/train/probe-mirrors2.sh +20 -0
- package/scripts/train/setup-wsl.sh +23 -0
- package/scripts/train/setup-wsl2.sh +25 -0
- package/scripts/train/setup-wsl3.sh +22 -0
- package/scripts/train/setup-wsl4.sh +22 -0
- package/scripts/train/train-lora.py +319 -0
- package/scripts/vram-free.py +104 -0
- package/scripts/wechat-full-pull.mjs +1 -1
- package/settings-host.js +1047 -12
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""fan-curve.py —— 把 FanControl 的「固定占空比」改成「温度曲线」。
|
|
3
|
+
|
|
4
|
+
背景(2026-12-02 主人反馈):
|
|
5
|
+
原来 4 个风扇全是 ManualControl=True + 固定值(CPU 38%、进风 26%、出风 26%、GPU 24%),
|
|
6
|
+
FanCurves 是空数组 —— 也就是说根本不是曲线:升温不升速、降温也不降速。
|
|
7
|
+
这里生成 graph 曲线并挂到对应风扇上,同时把 ManualControl 关掉。
|
|
8
|
+
|
|
9
|
+
安全策略:
|
|
10
|
+
· 动手前一定备份 userConfig.json(FanControl 目录 + config/fan/ 各一份)
|
|
11
|
+
· MinimumPercent 一律 ≥ 25:即使曲线读不到温度,也不会把风扇压到 0
|
|
12
|
+
· --restore 用最近一份备份回滚
|
|
13
|
+
|
|
14
|
+
⚠️ 实测结论(2026-12-02):FanControl 的 graph 曲线是 UI 里创建时序列化的内部结构,
|
|
15
|
+
用 --config 从命令行注入 **不生效**(做过对照实验:写成恒定 40% 的曲线,风扇仍是 33%)。
|
|
16
|
+
所以本脚本现在只用来**产出一份参数表**(config/fan/curve.json),真正落地要在
|
|
17
|
+
FanControl 界面里点「新建曲线 → 图形 → 选温度源 → 填下面的点」。--apply 仅作实验保留。
|
|
18
|
+
|
|
19
|
+
用法:
|
|
20
|
+
python scripts/fan-curve.py --dry-run # 只生成 config/fan/curve.json,不动运行中的实例
|
|
21
|
+
python scripts/fan-curve.py --apply # 生成 + FanControl --config 热加载
|
|
22
|
+
python scripts/fan-curve.py --status # 看当前温度/风扇/期望占空比
|
|
23
|
+
python scripts/fan-curve.py --restore # 回滚到最近备份
|
|
24
|
+
"""
|
|
25
|
+
import argparse
|
|
26
|
+
import json
|
|
27
|
+
import os
|
|
28
|
+
import shutil
|
|
29
|
+
import subprocess
|
|
30
|
+
import sys
|
|
31
|
+
import time
|
|
32
|
+
from datetime import datetime
|
|
33
|
+
|
|
34
|
+
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
35
|
+
FC_DIR = r"C:\Program Files (x86)\FanControl"
|
|
36
|
+
FC_EXE = os.path.join(FC_DIR, "FanControl.exe")
|
|
37
|
+
FC_USER_CFG = os.path.join(FC_DIR, "Configurations", "userConfig.json")
|
|
38
|
+
CFG_DIR = os.path.join(ROOT, "config", "fan")
|
|
39
|
+
OUT_CFG = os.path.join(CFG_DIR, "curve.json")
|
|
40
|
+
CNW = 0x08000000
|
|
41
|
+
|
|
42
|
+
# 同一设备下的温度传感器一般与 control 同路径,只是段名从 control 换成 temperature
|
|
43
|
+
CURVES = [
|
|
44
|
+
# key, 控制卡匹配(字段, 子串), 曲线名, 温度传感器标识, 曲线点(℃,%)
|
|
45
|
+
("cpu", "name", "CPU Fan", "CPU 温度曲线", "/lpc/nct6797d/temperature/0",
|
|
46
|
+
[[35, 30], [50, 40], [62, 52], [70, 65], [80, 85]]),
|
|
47
|
+
("in", "name", "进风", "进风 温度曲线", "/lpc/nct6797d/temperature/1",
|
|
48
|
+
[[30, 25], [45, 32], [60, 45], [70, 60], [80, 75]]),
|
|
49
|
+
("out", "name", "出风", "出风 温度曲线", "/lpc/nct6797d/temperature/2",
|
|
50
|
+
[[30, 25], [45, 35], [60, 50], [70, 65], [80, 80]]),
|
|
51
|
+
("gpu", "identifier", "NVApiWrapper", "GPU 温度曲线", "NVApiWrapper/0-TU102-A/temperature/0",
|
|
52
|
+
[[40, 25], [55, 35], [65, 50], [72, 65], [80, 80], [86, 90]]),
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def log(m):
|
|
57
|
+
print("[fan-curve] %s" % m, flush=True)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def smi(*fields):
|
|
61
|
+
try:
|
|
62
|
+
out = subprocess.run(["nvidia-smi", "--query-gpu=" + ",".join(fields),
|
|
63
|
+
"--format=csv,noheader,nounits"],
|
|
64
|
+
capture_output=True, text=True, timeout=15, creationflags=CNW)
|
|
65
|
+
row = (out.stdout or "").strip().splitlines()
|
|
66
|
+
return [x.strip() for x in row[0].split(",")] if row else None
|
|
67
|
+
except Exception:
|
|
68
|
+
return None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def load_cfg():
|
|
72
|
+
with open(FC_USER_CFG, "r", encoding="utf-8-sig") as f:
|
|
73
|
+
return json.load(f)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def backup():
|
|
77
|
+
os.makedirs(CFG_DIR, exist_ok=True)
|
|
78
|
+
ts = datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
79
|
+
a = os.path.join(CFG_DIR, "backup-userConfig-%s.json" % ts)
|
|
80
|
+
shutil.copyfile(FC_USER_CFG, a)
|
|
81
|
+
b = os.path.join(FC_DIR, "Configurations", "userConfig.before-curve-%s.json" % ts)
|
|
82
|
+
try:
|
|
83
|
+
shutil.copyfile(FC_USER_CFG, b)
|
|
84
|
+
except Exception as e:
|
|
85
|
+
log("写入 FanControl 目录备份失败(不影响,仓库里还有一份): %s" % e)
|
|
86
|
+
b = ""
|
|
87
|
+
return a, b
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def build(flat=None):
|
|
91
|
+
cfg = load_cfg()
|
|
92
|
+
fc = cfg["FanControl"]
|
|
93
|
+
curves = fc.setdefault("FanCurves", [])
|
|
94
|
+
by_name = {c.get("Name"): c for c in curves if isinstance(c, dict)}
|
|
95
|
+
matched = []
|
|
96
|
+
for key, how, pat, name, sensor, points in CURVES:
|
|
97
|
+
if flat:
|
|
98
|
+
points = [[30, flat], [60, flat]]
|
|
99
|
+
curve = {
|
|
100
|
+
"Name": name,
|
|
101
|
+
"IsHidden": False,
|
|
102
|
+
"CommandMode": 2, # 2 = graph(0=fixed,1=linear)
|
|
103
|
+
# Points 的元素是 System.Windows.Point,Newtonsoft 走 TypeConverter → 必须是 "x,y" 字符串
|
|
104
|
+
"Points": ["%s,%s" % (int(t), int(p)) for t, p in points],
|
|
105
|
+
"SelectedTempSensors": [{"Identifier": sensor}],
|
|
106
|
+
}
|
|
107
|
+
if name in by_name:
|
|
108
|
+
by_name[name].update(curve)
|
|
109
|
+
else:
|
|
110
|
+
curves.append(curve)
|
|
111
|
+
for card in fc["Controls"]:
|
|
112
|
+
hay = (card.get("Identifier") if how == "identifier" else card.get("NickName")) or ""
|
|
113
|
+
if pat.lower() not in hay.lower():
|
|
114
|
+
continue
|
|
115
|
+
card["Enable"] = True
|
|
116
|
+
card["ManualControl"] = False
|
|
117
|
+
# FanControl 的 SelectedFanCurve 存的是**曲线对象本体**,不是名字;
|
|
118
|
+
# 写成字符串会让整个配置反序列化失败(log.txt: "Current JsonReader item is not an object: String")
|
|
119
|
+
card["SelectedFanCurve"] = json.loads(json.dumps(curve))
|
|
120
|
+
card["MinimumPercent"] = max(int(card.get("MinimumPercent") or 0), 25)
|
|
121
|
+
card["MaximumPercent"] = 100
|
|
122
|
+
card["SelectedStart"] = 0
|
|
123
|
+
card["SelectedStop"] = 0
|
|
124
|
+
matched.append((key, card.get("NickName"), points))
|
|
125
|
+
cfg["FanControl"] = fc
|
|
126
|
+
os.makedirs(CFG_DIR, exist_ok=True)
|
|
127
|
+
with open(OUT_CFG, "w", encoding="utf-8") as f:
|
|
128
|
+
json.dump(cfg, f, ensure_ascii=False, indent=2)
|
|
129
|
+
return OUT_CFG, matched
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def expected(key, temp):
|
|
133
|
+
pts = next((p for k, _h, _pat, _n, _s, p in CURVES if k == key), None)
|
|
134
|
+
if not pts or temp is None:
|
|
135
|
+
return None
|
|
136
|
+
if temp <= pts[0][0]:
|
|
137
|
+
return pts[0][1]
|
|
138
|
+
for (t0, p0), (t1, p1) in zip(pts, pts[1:]):
|
|
139
|
+
if t0 <= temp <= t1:
|
|
140
|
+
return round(p0 + (p1 - p0) * (temp - t0) / max(1e-6, t1 - t0))
|
|
141
|
+
return pts[-1][1]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def apply_cfg(path):
|
|
145
|
+
if not os.path.exists(FC_EXE):
|
|
146
|
+
log("找不到 FanControl.exe")
|
|
147
|
+
return 3
|
|
148
|
+
try:
|
|
149
|
+
p = subprocess.Popen([FC_EXE, "-c", path], creationflags=CNW)
|
|
150
|
+
p.wait(timeout=25)
|
|
151
|
+
except Exception as e:
|
|
152
|
+
log("--config 调用失败: %s" % e)
|
|
153
|
+
return 3
|
|
154
|
+
return 0
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def status():
|
|
158
|
+
row = smi("temperature.gpu", "fan.speed", "power.draw")
|
|
159
|
+
if row:
|
|
160
|
+
t, f, p = row[0], row[1], row[2]
|
|
161
|
+
exp = expected("gpu", float(t))
|
|
162
|
+
print("gpu : %s C fan %s%% 期望(GPU 曲线) %s%% power %s W" % (t, f, exp, p))
|
|
163
|
+
else:
|
|
164
|
+
print("nvidia-smi 不可用")
|
|
165
|
+
print("cfg : %s" % (OUT_CFG if os.path.exists(OUT_CFG) else "未生成"))
|
|
166
|
+
try:
|
|
167
|
+
j = load_cfg()
|
|
168
|
+
for c in j["FanControl"]["Controls"]:
|
|
169
|
+
print(" %-34s manual=%-5s curve=%s min=%s" %
|
|
170
|
+
(c.get("NickName"), c.get("ManualControl"), c.get("SelectedFanCurve"),
|
|
171
|
+
c.get("MinimumPercent")))
|
|
172
|
+
print("curves: %s" % ", ".join(x.get("Name", "?") for x in j["FanControl"]["FanCurves"]))
|
|
173
|
+
except Exception as e:
|
|
174
|
+
print("读配置失败: %s" % e)
|
|
175
|
+
return 0
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def restore():
|
|
179
|
+
cands = sorted([f for f in os.listdir(CFG_DIR) if f.startswith("backup-userConfig-")])
|
|
180
|
+
if not cands:
|
|
181
|
+
log("没有备份可回滚")
|
|
182
|
+
return 2
|
|
183
|
+
src = os.path.join(CFG_DIR, cands[-1])
|
|
184
|
+
shutil.copyfile(src, FC_USER_CFG)
|
|
185
|
+
log("已回滚: %s -> userConfig.json" % cands[-1])
|
|
186
|
+
return apply_cfg(FC_USER_CFG)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def main():
|
|
190
|
+
ap = argparse.ArgumentParser()
|
|
191
|
+
ap.add_argument("--dry-run", action="store_true")
|
|
192
|
+
ap.add_argument("--apply", action="store_true")
|
|
193
|
+
ap.add_argument("--status", action="store_true")
|
|
194
|
+
ap.add_argument("--test-percent", type=int, default=0,
|
|
195
|
+
help="把所有曲线压成恒定值做对照实验(验证曲线是否真的生效)")
|
|
196
|
+
ap.add_argument("--restore", action="store_true")
|
|
197
|
+
a = ap.parse_args()
|
|
198
|
+
if a.status:
|
|
199
|
+
return status()
|
|
200
|
+
if a.restore:
|
|
201
|
+
return restore()
|
|
202
|
+
ba, bb = backup()
|
|
203
|
+
log("已备份: %s" % ba)
|
|
204
|
+
path, matched = build(flat=a.test_percent or None)
|
|
205
|
+
for k, n, pts in matched:
|
|
206
|
+
log("挂曲线 %-8s -> %-30s %s" % (k, n, pts))
|
|
207
|
+
log("已生成 %s" % path)
|
|
208
|
+
if not a.apply:
|
|
209
|
+
log("未应用(加 --apply 才热加载到运行中的 FanControl)")
|
|
210
|
+
return 0
|
|
211
|
+
rc = apply_cfg(path)
|
|
212
|
+
time.sleep(8)
|
|
213
|
+
status()
|
|
214
|
+
return rc
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
if __name__ == "__main__":
|
|
218
|
+
sys.exit(main())
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""fan-mode.py —— FanControl 三档风扇 + 温度看门狗(日常 / 中间 / 训练)
|
|
3
|
+
|
|
4
|
+
为什么重写(2026-12-04):
|
|
5
|
+
原来只有 daily / task 两档,且切换全靠别的脚本手动调用 —— 没有任何进程在看温度,
|
|
6
|
+
所以 GPU 跑到 88C 风扇还停在固定值上,"超过 80 度就切散热"从来没真正发生过。
|
|
7
|
+
现在:三档固定占空比(不建曲线、不靠温度源判断,切过去就是死值),
|
|
8
|
+
外加一个 --watch 看门狗:GPU/CPU 过 80C 进训练档,降回 74C 以下退日常档,中间走中间档。
|
|
9
|
+
|
|
10
|
+
档位数值(主人 2026-12-04 给定,别再自己发挥):
|
|
11
|
+
日常 daily : GPU 22 CPU 30 进风 23 出风 23
|
|
12
|
+
中间 medium: GPU 61 CPU 50 进风 29 出风 29
|
|
13
|
+
训练 train : GPU 70 CPU 66 进风 35 出风 35
|
|
14
|
+
|
|
15
|
+
用法:
|
|
16
|
+
python scripts/fan-mode.py --status # 看当前温度/风扇/档位
|
|
17
|
+
python scripts/fan-mode.py --apply train # 切训练档
|
|
18
|
+
python scripts/fan-mode.py --apply medium
|
|
19
|
+
python scripts/fan-mode.py --apply daily
|
|
20
|
+
python scripts/fan-mode.py --task # 兼容旧调用,等价于 --apply train
|
|
21
|
+
python scripts/fan-mode.py --daily # 兼容旧调用
|
|
22
|
+
python scripts/fan-mode.py --watch # 常驻看门狗(>80C 自动进训练档)
|
|
23
|
+
"""
|
|
24
|
+
import argparse
|
|
25
|
+
import ctypes
|
|
26
|
+
import json
|
|
27
|
+
import os
|
|
28
|
+
import subprocess
|
|
29
|
+
import sys
|
|
30
|
+
import time
|
|
31
|
+
from datetime import datetime
|
|
32
|
+
|
|
33
|
+
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
34
|
+
FC_EXE = r"C:\Program Files (x86)\FanControl\FanControl.exe"
|
|
35
|
+
FC_USER_CFG = r"C:\Program Files (x86)\FanControl\Configurations\userConfig.json"
|
|
36
|
+
CFG_DIR = os.path.join(ROOT, "config", "fan")
|
|
37
|
+
STATE_FILE = os.path.join(CFG_DIR, "state.json")
|
|
38
|
+
LOG_FILE = os.path.join(ROOT, "logs", "fan.log")
|
|
39
|
+
CREATE_NO_WINDOW = 0x08000000
|
|
40
|
+
|
|
41
|
+
# 档位定义:key -> (cpu, in, out, gpu)
|
|
42
|
+
PROFILES = {
|
|
43
|
+
"daily": {"cpu": 30, "in": 23, "out": 23, "gpu": 22},
|
|
44
|
+
"medium": {"cpu": 50, "in": 29, "out": 29, "gpu": 61},
|
|
45
|
+
"train": {"cpu": 66, "in": 35, "out": 35, "gpu": 70},
|
|
46
|
+
}
|
|
47
|
+
ALIAS = {"task": "train"} # 旧名字
|
|
48
|
+
# 看门狗阈值(带迟滞,避免在阈值上反复横跳)
|
|
49
|
+
T_HOT = 80 # >= 80C 进训练档
|
|
50
|
+
T_WARM = 74 # 74~80C 中间档
|
|
51
|
+
T_COOL = 64 # <= 64C 才回日常档。61% 风扇的平衡点就在 68~70C,阈值贴着平衡点会
|
|
52
|
+
# 每两分钟切一次(实测 10:30/10:32 连切),留到 64C 才不会来回叫
|
|
53
|
+
POLL_SEC = 15
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def log(msg):
|
|
57
|
+
line = "%s %s" % (datetime.now().strftime("%Y-%m-%d %H:%M:%S"), msg)
|
|
58
|
+
print(line, flush=True)
|
|
59
|
+
try:
|
|
60
|
+
os.makedirs(os.path.dirname(LOG_FILE), exist_ok=True)
|
|
61
|
+
with open(LOG_FILE, "a", encoding="utf-8") as f:
|
|
62
|
+
f.write(line + "\n")
|
|
63
|
+
except OSError:
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def smi(*fields):
|
|
68
|
+
try:
|
|
69
|
+
out = subprocess.run(
|
|
70
|
+
["nvidia-smi", "--query-gpu=" + ",".join(fields), "--format=csv,noheader,nounits"],
|
|
71
|
+
capture_output=True, text=True, timeout=15, creationflags=CREATE_NO_WINDOW)
|
|
72
|
+
rows = (out.stdout or "").strip().splitlines()
|
|
73
|
+
return [x.strip() for x in rows[0].split(",")] if rows else None
|
|
74
|
+
except Exception:
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def gpu_temp():
|
|
79
|
+
row = smi("temperature.gpu")
|
|
80
|
+
try:
|
|
81
|
+
return int(float(row[0]))
|
|
82
|
+
except Exception:
|
|
83
|
+
return None
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def gpu_fan():
|
|
87
|
+
row = smi("fan.speed")
|
|
88
|
+
try:
|
|
89
|
+
return int(float(row[0]))
|
|
90
|
+
except Exception:
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def cpu_temp():
|
|
95
|
+
"""CPU 温度:走 ACPI 热区。很多台式板子不暴露,读不到就返回 None(不阻塞判断)。"""
|
|
96
|
+
try:
|
|
97
|
+
out = subprocess.run(
|
|
98
|
+
["powershell", "-NoProfile", "-Command",
|
|
99
|
+
"(Get-CimInstance -Namespace root/wmi -ClassName MSAcpi_ThermalZoneTemperature "
|
|
100
|
+
"-ErrorAction Stop | Select-Object -First 1).CurrentTemperature"],
|
|
101
|
+
capture_output=True, text=True, timeout=10, creationflags=CREATE_NO_WINDOW,
|
|
102
|
+
encoding="gbk", errors="ignore")
|
|
103
|
+
raw = (out.stdout or "").strip()
|
|
104
|
+
if not raw:
|
|
105
|
+
return None
|
|
106
|
+
return int(round(int(float(raw)) / 10.0 - 273.15))
|
|
107
|
+
except Exception:
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _card_key(ident, nick):
|
|
112
|
+
hay_id = (ident or "").lower()
|
|
113
|
+
hay_nick = (nick or "").lower()
|
|
114
|
+
# 显卡卡的 Identifier 实际是 'NVApiWrapper/0-TU102-A/control/0'
|
|
115
|
+
# (旧代码写成 nvaapiwrapper,多了一个 a,所以三条配置里的 GPU 值从来没被改到)
|
|
116
|
+
if "nvapiwrapper" in hay_id or hay_id.startswith("nvapi"):
|
|
117
|
+
return "gpu"
|
|
118
|
+
if "cpu fan" in hay_nick:
|
|
119
|
+
return "cpu"
|
|
120
|
+
if "进风" in hay_nick:
|
|
121
|
+
return "in"
|
|
122
|
+
if "出风" in hay_nick:
|
|
123
|
+
return "out"
|
|
124
|
+
return None
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def read_source_config():
|
|
128
|
+
with open(FC_USER_CFG, "r", encoding="utf-8-sig") as f:
|
|
129
|
+
return json.load(f)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def build(force=False):
|
|
133
|
+
"""按三档目标值生成 daily/medium/train 三份模板;值不对就重建(不自作主张改数值)。"""
|
|
134
|
+
os.makedirs(CFG_DIR, exist_ok=True)
|
|
135
|
+
paths = {k: os.path.join(CFG_DIR, k + ".json") for k in PROFILES}
|
|
136
|
+
if not force and all(os.path.exists(p) for p in paths.values()):
|
|
137
|
+
# 模板被 FanControl 回写坏过(实测 medium 变成 35),所以存在也要核对数值
|
|
138
|
+
if all(_template_ok(p, PROFILES[k]) for k, p in paths.items()):
|
|
139
|
+
return paths
|
|
140
|
+
cfg = read_source_config()
|
|
141
|
+
for name, targets in PROFILES.items():
|
|
142
|
+
data = json.loads(json.dumps(cfg))
|
|
143
|
+
for card in data["FanControl"]["Controls"]:
|
|
144
|
+
key = _card_key(card.get("Identifier"), card.get("NickName"))
|
|
145
|
+
if not key:
|
|
146
|
+
continue
|
|
147
|
+
card["Enable"] = True
|
|
148
|
+
card["ManualControl"] = True # 固定值,不用曲线
|
|
149
|
+
card["ManualControlValue"] = int(targets[key])
|
|
150
|
+
tmp = paths[name] + ".tmp"
|
|
151
|
+
with open(tmp, "w", encoding="utf-8") as f:
|
|
152
|
+
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
153
|
+
os.replace(tmp, paths[name])
|
|
154
|
+
log("已生成三档配置: " + ", ".join("%s(GPU %d%%)" % (k, v["gpu"]) for k, v in PROFILES.items()))
|
|
155
|
+
return paths
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _template_ok(path, targets):
|
|
159
|
+
try:
|
|
160
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
161
|
+
data = json.load(f)
|
|
162
|
+
for card in data["FanControl"]["Controls"]:
|
|
163
|
+
key = _card_key(card.get("Identifier"), card.get("NickName"))
|
|
164
|
+
if key and int(card.get("ManualControlValue", -1)) != int(targets[key]):
|
|
165
|
+
return False
|
|
166
|
+
return True
|
|
167
|
+
except Exception:
|
|
168
|
+
return False
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def fancontrol_running():
|
|
172
|
+
try:
|
|
173
|
+
out = subprocess.run(["tasklist", "/FI", "IMAGENAME eq FanControl.exe", "/NH"],
|
|
174
|
+
capture_output=True, text=True, timeout=15,
|
|
175
|
+
encoding="gbk", errors="ignore",
|
|
176
|
+
creationflags=CREATE_NO_WINDOW)
|
|
177
|
+
return "FanControl.exe" in (out.stdout or "")
|
|
178
|
+
except Exception:
|
|
179
|
+
return False
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def write_state(profile, ok, note=""):
|
|
183
|
+
os.makedirs(CFG_DIR, exist_ok=True)
|
|
184
|
+
data = {"profile": profile if ok else "unknown", "ok": bool(ok),
|
|
185
|
+
"gpu_temp": gpu_temp(), "gpu_fan": gpu_fan(), "note": note,
|
|
186
|
+
"at": datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
|
|
187
|
+
tmp = STATE_FILE + ".tmp"
|
|
188
|
+
with open(tmp, "w", encoding="utf-8") as f:
|
|
189
|
+
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
190
|
+
os.replace(tmp, STATE_FILE)
|
|
191
|
+
return data
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def current_profile():
|
|
195
|
+
try:
|
|
196
|
+
with open(STATE_FILE, "r", encoding="utf-8") as f:
|
|
197
|
+
return (json.load(f) or {}).get("profile")
|
|
198
|
+
except Exception:
|
|
199
|
+
return None
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def is_admin():
|
|
203
|
+
"""FanControl.exe -c 只有管理员才真正生效:非管理员调用会「成功返回、风扇不动」。"""
|
|
204
|
+
try:
|
|
205
|
+
return bool(ctypes.windll.shell32.IsUserAnAdmin())
|
|
206
|
+
except Exception:
|
|
207
|
+
return False
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def relaunch_as_admin():
|
|
211
|
+
"""把自己以管理员身份重开一次(UAC 弹窗)。换档/看门狗必须走这条路,否则等于没切。"""
|
|
212
|
+
params = " ".join('"%s"' % a for a in sys.argv[1:])
|
|
213
|
+
try:
|
|
214
|
+
rc = ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, params, None, 1)
|
|
215
|
+
return rc > 32
|
|
216
|
+
except Exception as e:
|
|
217
|
+
log("申请管理员权限失败: %s" % e)
|
|
218
|
+
return False
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def apply(profile, wait=20):
|
|
222
|
+
name = ALIAS.get(profile, profile)
|
|
223
|
+
if name not in PROFILES:
|
|
224
|
+
log("未知档位: %s" % profile)
|
|
225
|
+
return 2
|
|
226
|
+
if not is_admin():
|
|
227
|
+
# 非管理员调 FanControl -c 会「返回成功但风扇不动」,那正是之前 88C 的原因
|
|
228
|
+
log("切 %s 档被拒绝:当前不是管理员,FanControl 接收配置但不执行" % name)
|
|
229
|
+
return 5
|
|
230
|
+
if not os.path.exists(FC_EXE):
|
|
231
|
+
log("找不到 FanControl.exe: %s" % FC_EXE)
|
|
232
|
+
return 3
|
|
233
|
+
cfg = build(force=False)[name] # 三档模板(只读,不给 FanControl 加载)
|
|
234
|
+
active = os.path.join(CFG_DIR, "active.json")
|
|
235
|
+
want = PROFILES[name]["gpu"]
|
|
236
|
+
# ★ 只改文件再 -c 重新加载并不可靠:实测同一进程里 reload 之后风扇还是按旧曲线跑
|
|
237
|
+
# (61% 目标实际只到 35~42%)。所以换档 = 先把 FanControl 停掉、再按新配置冷启动,
|
|
238
|
+
# 这样它一定是「启动即加载」,三档占空比才会真的落到风扇上。
|
|
239
|
+
try:
|
|
240
|
+
subprocess.run(["taskkill", "/IM", "FanControl.exe", "/F"], capture_output=True,
|
|
241
|
+
timeout=20, creationflags=CREATE_NO_WINDOW)
|
|
242
|
+
time.sleep(1.5)
|
|
243
|
+
except Exception:
|
|
244
|
+
pass
|
|
245
|
+
# 必须在停掉之后写 active.json:FanControl 退出时会把实时值回写它加载的那个文件
|
|
246
|
+
try:
|
|
247
|
+
with open(cfg, "r", encoding="utf-8") as f:
|
|
248
|
+
data = json.load(f)
|
|
249
|
+
with open(active, "w", encoding="utf-8") as f:
|
|
250
|
+
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
251
|
+
except Exception as e:
|
|
252
|
+
log("写 active.json 失败: %s" % e)
|
|
253
|
+
return 3
|
|
254
|
+
try:
|
|
255
|
+
subprocess.Popen([FC_EXE, "-c", active, "-m"], creationflags=CREATE_NO_WINDOW)
|
|
256
|
+
except Exception as e:
|
|
257
|
+
log("拉起 FanControl 失败: %s" % e)
|
|
258
|
+
return 3
|
|
259
|
+
|
|
260
|
+
t0, cur = time.time(), gpu_fan()
|
|
261
|
+
while time.time() - t0 < wait:
|
|
262
|
+
time.sleep(2)
|
|
263
|
+
cur = gpu_fan()
|
|
264
|
+
if cur is None or abs(cur - want) <= 5:
|
|
265
|
+
break
|
|
266
|
+
ok = True if cur is None else (abs(cur - want) <= 8)
|
|
267
|
+
write_state(name, ok, "gpu_fan=%s want=%s" % (cur, want))
|
|
268
|
+
log("切到 %s 档 -> GPU 风扇 %s%%(目标 %s%%)%s" % (name, cur, want, "" if ok else " ⚠ 未达预期"))
|
|
269
|
+
return 0 if ok else 4
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def pick_profile(temp, cur=None):
|
|
273
|
+
"""带迟滞的三档判定:只在「确实该换」时才换,避免在阈值上每 15 秒来回跳。
|
|
274
|
+
|
|
275
|
+
>=80C → train(不管现在哪档)
|
|
276
|
+
74~80C → 现在已经在 train 就保持(让它再压下去),否则 medium
|
|
277
|
+
70~74C → 死区,保持不动
|
|
278
|
+
<=70C → daily
|
|
279
|
+
"""
|
|
280
|
+
if temp is None:
|
|
281
|
+
return None
|
|
282
|
+
if temp >= T_HOT:
|
|
283
|
+
return "train"
|
|
284
|
+
if temp <= T_COOL:
|
|
285
|
+
return "daily"
|
|
286
|
+
if temp >= T_WARM:
|
|
287
|
+
return "train" if cur == "train" else "medium"
|
|
288
|
+
return None # 70~74 死区
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def fan_ok(profile, tol=10):
|
|
292
|
+
"""实际风扇是否真的到了该档的目标值(state.json 写的是「意图」,不是事实)。"""
|
|
293
|
+
f = gpu_fan()
|
|
294
|
+
if f is None:
|
|
295
|
+
return True
|
|
296
|
+
return abs(f - PROFILES[profile]["gpu"]) <= tol
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def watch():
|
|
300
|
+
log("看门狗启动:>=%dC 训练档 / %d~%dC 中间档 / <=%dC 日常档,每 %ds 轮询"
|
|
301
|
+
% (T_HOT, T_WARM, T_HOT, T_COOL, POLL_SEC))
|
|
302
|
+
last_retry = 0.0
|
|
303
|
+
while True:
|
|
304
|
+
try:
|
|
305
|
+
tg, tc = gpu_temp(), cpu_temp()
|
|
306
|
+
hot = max([x for x in (tg, tc) if x is not None] or [None])
|
|
307
|
+
cur = current_profile()
|
|
308
|
+
want = pick_profile(hot, cur)
|
|
309
|
+
need = bool(want) and want != cur
|
|
310
|
+
# 配置写进去了但风扇没跟上(FanControl 自己回写配置就是这种坑)→ 60 秒重试一次
|
|
311
|
+
if want and not need and not fan_ok(want) and time.time() - last_retry > 60:
|
|
312
|
+
log("风扇没跟上:当前 %s%% / %s 档目标 %d%% → 重新下发"
|
|
313
|
+
% (gpu_fan(), want, PROFILES[want]["gpu"]))
|
|
314
|
+
last_retry = time.time()
|
|
315
|
+
need = True
|
|
316
|
+
if need:
|
|
317
|
+
log("温度 GPU=%s CPU=%s -> 切 %s 档" % (tg, tc, want))
|
|
318
|
+
apply(want)
|
|
319
|
+
time.sleep(POLL_SEC)
|
|
320
|
+
except KeyboardInterrupt:
|
|
321
|
+
log("看门狗退出")
|
|
322
|
+
return 0
|
|
323
|
+
except Exception as e:
|
|
324
|
+
log("看门狗异常(继续跑): %s" % e)
|
|
325
|
+
time.sleep(POLL_SEC)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def status():
|
|
329
|
+
row = smi("name", "temperature.gpu", "fan.speed", "power.draw", "power.limit", "memory.used")
|
|
330
|
+
if row:
|
|
331
|
+
print("gpu : %s" % row[0])
|
|
332
|
+
print("temp : %s C fan: %s%% power: %s / %s W" % tuple(row[1:5]))
|
|
333
|
+
print("vram : %s MiB" % row[5])
|
|
334
|
+
else:
|
|
335
|
+
print("nvidia-smi 不可用")
|
|
336
|
+
print("cpu : %s C" % cpu_temp())
|
|
337
|
+
print("fanctl: %s" % ("running" if fancontrol_running() else "NOT running"))
|
|
338
|
+
print("mode : %s" % (current_profile() or "未知(还没切过档)"))
|
|
339
|
+
for name in PROFILES:
|
|
340
|
+
p = os.path.join(CFG_DIR, name + ".json")
|
|
341
|
+
print("%-6s: %s (GPU %d%%)" % (name, "ok" if os.path.exists(p) else "缺失", PROFILES[name]["gpu"]))
|
|
342
|
+
return 0
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def main():
|
|
346
|
+
ap = argparse.ArgumentParser()
|
|
347
|
+
ap.add_argument("--status", action="store_true")
|
|
348
|
+
ap.add_argument("--make", action="store_true")
|
|
349
|
+
ap.add_argument("--force", action="store_true")
|
|
350
|
+
ap.add_argument("--watch", action="store_true")
|
|
351
|
+
ap.add_argument("--task", action="store_true")
|
|
352
|
+
ap.add_argument("--daily", action="store_true")
|
|
353
|
+
ap.add_argument("--apply", choices=list(PROFILES) + ["task"])
|
|
354
|
+
a = ap.parse_args()
|
|
355
|
+
|
|
356
|
+
if a.status:
|
|
357
|
+
return status()
|
|
358
|
+
if a.make:
|
|
359
|
+
build(force=a.force)
|
|
360
|
+
return status()
|
|
361
|
+
# 换档 / 看门狗:非管理员先自我提权重开,否则切了等于没切
|
|
362
|
+
if (a.watch or a.apply or a.task or a.daily) and not is_admin():
|
|
363
|
+
log("非管理员启动,正在申请管理员权限重开(UAC 请点「是」)")
|
|
364
|
+
if relaunch_as_admin():
|
|
365
|
+
return 0
|
|
366
|
+
log("没有拿到管理员权限 —— 风扇不会真的动")
|
|
367
|
+
return 5
|
|
368
|
+
if a.watch:
|
|
369
|
+
return watch()
|
|
370
|
+
if a.apply:
|
|
371
|
+
return apply(a.apply)
|
|
372
|
+
if a.task:
|
|
373
|
+
return apply("train")
|
|
374
|
+
if a.daily:
|
|
375
|
+
return apply("daily")
|
|
376
|
+
return status()
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
if __name__ == "__main__":
|
|
380
|
+
sys.exit(main())
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""把风扇控制项临时切回手动值(曲线没有温度源,不能上线)。"""
|
|
3
|
+
import io, json, shutil, os, datetime, subprocess, time
|
|
4
|
+
|
|
5
|
+
CFG = r"C:\Program Files (x86)\FanControl\Configurations\userConfig.json"
|
|
6
|
+
bak = CFG + ".bak-before-manual-" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
7
|
+
shutil.copy2(CFG, bak)
|
|
8
|
+
print("backup ->", bak)
|
|
9
|
+
|
|
10
|
+
d = json.load(io.open(CFG, encoding="utf-8"))
|
|
11
|
+
ctl = d["FanControl"]["Controls"]
|
|
12
|
+
for c in ctl:
|
|
13
|
+
name = c.get("NickName") or ""
|
|
14
|
+
if c.get("Identifier") == "NVApiWrapper/0-TU102-A/control/0":
|
|
15
|
+
c["Enable"] = True; c["ManualControl"] = True; c["ManualControlValue"] = 15; c["SelectedFanCurve"] = None
|
|
16
|
+
elif "CPU" in name:
|
|
17
|
+
c["Enable"] = True; c["ManualControl"] = True; c["ManualControlValue"] = 30; c["SelectedFanCurve"] = None
|
|
18
|
+
elif "SYS_FAN2" in name or "SYS_FAN4" in name:
|
|
19
|
+
c["Enable"] = True; c["ManualControl"] = True; c["ManualControlValue"] = 30; c["SelectedFanCurve"] = None
|
|
20
|
+
elif "System Fan #1" in name:
|
|
21
|
+
c["Enable"] = True; c["ManualControl"] = True; c["ManualControlValue"] = 25; c["SelectedFanCurve"] = None
|
|
22
|
+
elif "System Fan #3" in name:
|
|
23
|
+
c["Enable"] = True; c["ManualControl"] = True; c["ManualControlValue"] = 25; c["SelectedFanCurve"] = None
|
|
24
|
+
elif "芯片组" in name:
|
|
25
|
+
c["Enable"] = False; c["ManualControl"] = True; c["ManualControlValue"] = 25; c["SelectedFanCurve"] = None
|
|
26
|
+
io.open(CFG, "w", encoding="utf-8", newline="\n").write(json.dumps(d, ensure_ascii=False, indent=2))
|
|
27
|
+
print("config rewritten (manual, curves detached)")
|
|
28
|
+
|
|
29
|
+
subprocess.run(["taskkill", "/IM", "FanControl.exe", "/F"], capture_output=True)
|
|
30
|
+
time.sleep(2)
|
|
31
|
+
subprocess.Popen([r"C:\Program Files (x86)\FanControl\FanControl.exe"])
|
|
32
|
+
time.sleep(10)
|
|
33
|
+
print("FanControl restarted")
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""恢复风扇为可用状态:以 22:57 的冻结配置为底,改成手动曲线(有效 JSON 结构)。"""
|
|
3
|
+
import io, json, shutil, os, subprocess, time, datetime
|
|
4
|
+
|
|
5
|
+
CFGDIR = r"C:\Program Files (x86)\FanControl\Configurations"
|
|
6
|
+
CFG = os.path.join(CFGDIR, "userConfig.json")
|
|
7
|
+
SRC = os.path.join(CFGDIR, "userConfig.json.bak-gpu45-20261125-225709")
|
|
8
|
+
|
|
9
|
+
bak = CFG + ".bak-restore-" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
10
|
+
shutil.copy2(CFG, bak)
|
|
11
|
+
print("backup ->", bak)
|
|
12
|
+
|
|
13
|
+
if not os.path.exists(SRC):
|
|
14
|
+
raise SystemExit("missing source backup: " + SRC)
|
|
15
|
+
d = json.load(io.open(SRC, encoding="utf-8"))
|
|
16
|
+
fc = d["FanControl"]
|
|
17
|
+
|
|
18
|
+
# 有效结构:SelectedFanCurve 必须是对象或 null;曲线无温度源,先全部手动
|
|
19
|
+
for c in fc["Controls"]:
|
|
20
|
+
c["SelectedFanCurve"] = None
|
|
21
|
+
c["ManualControl"] = True
|
|
22
|
+
name = (c.get("NickName") or "")
|
|
23
|
+
if name == "Pump Fan":
|
|
24
|
+
c["Enable"] = False; c["ManualControlValue"] = 50
|
|
25
|
+
elif "CPU" in name:
|
|
26
|
+
c["Enable"] = True; c["ManualControlValue"] = 30
|
|
27
|
+
elif "SYS_FAN2" in name or "SYS_FAN4" in name:
|
|
28
|
+
c["Enable"] = True; c["ManualControlValue"] = 30
|
|
29
|
+
elif "System Fan #1" in name or "System Fan #3" in name:
|
|
30
|
+
c["Enable"] = True; c["ManualControlValue"] = 25
|
|
31
|
+
elif "芯片组" in name:
|
|
32
|
+
c["Enable"] = False; c["ManualControlValue"] = 25
|
|
33
|
+
elif "/NVApiWrapper/" in (c.get("Identifier") or "").replace("/0-TU102-A", "/"):
|
|
34
|
+
c["Enable"] = True; c["ManualControlValue"] = 15
|
|
35
|
+
elif "2080" in name or "NVApiWrapper" in (c.get("Identifier") or ""):
|
|
36
|
+
c["Enable"] = True; c["ManualControlValue"] = 15
|
|
37
|
+
|
|
38
|
+
io.open(CFG, "w", encoding="utf-8", newline="\n").write(json.dumps(d, ensure_ascii=False, indent=2))
|
|
39
|
+
print("config written")
|
|
40
|
+
|
|
41
|
+
subprocess.run(["taskkill", "/IM", "FanControl.exe", "/F"], capture_output=True)
|
|
42
|
+
time.sleep(2)
|
|
43
|
+
subprocess.Popen([r"C:\Program Files (x86)\FanControl\FanControl.exe"])
|
|
44
|
+
time.sleep(12)
|
|
45
|
+
subprocess.run(["nvidia-smi", "--query-gpu=fan.speed,temperature.gpu,power.draw", "--format=csv"])
|
|
46
|
+
print("done")
|