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
This commit is contained in:
43
FanControl.ChromeboxEC/PluginConfig.cs
Normal file
43
FanControl.ChromeboxEC/PluginConfig.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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 <sensorid>。默认 ["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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user