Files
jack 111eb22824 Add FanControl.ChromeboxEC plugin, project background, ectool docs
- Add FanControl.ChromeboxEC plugin for Fan Control
- Add project background/缘由 in README (EN/zh)
- Add docs/ectool-commands-zh.md
- Update sln, appsettings, gitignore

Made-with: Cursor
2026-03-22 15:15:02 +08:00

44 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Text.Json;
namespace FanControl.ChromeboxEC;
/// <summary>插件配置,对应 ectool 命令参数。参见 docs/ectool-commands-zh.md</summary>
public sealed class PluginConfig
{
/// <summary>ectool 可执行文件路径,默认 Coolstar 安装路径</summary>
public string EctoolPath { get; set; } = @"C:\Program Files\crosec\ectool.exe";
/// <summary>读取温度ectool temps &lt;sensorid&gt;。默认 ["temps", "0"],可用 tempsinfo 查本机传感器 ID</summary>
public string[] TempArgs { get; set; } = ["temps", "0"];
/// <summary>读取转速ectool pwmgetfanrpm [index|all]。默认 ["pwmgetfanrpm", "0"]</summary>
public string[] FanRpmArgs { get; set; } = ["pwmgetfanrpm", "0"];
/// <summary>恢复自动风扇ectool autofanctrl。禁用控制时调用</summary>
public string[] AutoFanCtrlArgs { get; set; } = ["autofanctrl"];
public static PluginConfig Load()
{
var paths = new[]
{
Path.Combine(AppContext.BaseDirectory, "FanControl.ChromeboxEC.json"),
Path.Combine(Path.GetDirectoryName(typeof(PluginConfig).Assembly.Location) ?? "", "FanControl.ChromeboxEC.json"),
Path.Combine(AppContext.BaseDirectory, "Plugins", "FanControl.ChromeboxEC.json"),
};
foreach (var configPath in paths)
{
if (string.IsNullOrEmpty(configPath) || !File.Exists(configPath))
continue;
try
{
var json = File.ReadAllText(configPath);
var cfg = JsonSerializer.Deserialize<PluginConfig>(json);
if (cfg != null)
return cfg;
}
catch { /* try next path */ }
}
return new PluginConfig();
}
}