- 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
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using FanControl.Plugins;
|
|
|
|
namespace FanControl.ChromeboxEC;
|
|
|
|
/// <summary>
|
|
/// Fan Control 插件:通过 ectool 读取 Chromebox EC 温度、控制风扇。
|
|
/// 命令参见 docs/ectool-commands-zh.md
|
|
/// </summary>
|
|
public sealed class ChromeboxECPlugin : IPlugin
|
|
{
|
|
private PluginConfig? _config;
|
|
private bool _available;
|
|
|
|
public string Name => "Chromebox EC";
|
|
|
|
public void Initialize()
|
|
{
|
|
_config = PluginConfig.Load();
|
|
_available = !string.IsNullOrWhiteSpace(_config.EctoolPath) &&
|
|
File.Exists(_config.EctoolPath);
|
|
}
|
|
|
|
public void Load(IPluginSensorsContainer container)
|
|
{
|
|
if (!_available || _config == null)
|
|
return;
|
|
|
|
var tempArgs = _config.TempArgs is { Length: > 0 } ta ? ta : ["temps", "0"];
|
|
var rpmArgs = _config.FanRpmArgs is { Length: > 0 } ra ? ra : ["pwmgetfanrpm", "0"];
|
|
|
|
container.TempSensors.Add(new ChromeboxECTempSensor(_config.EctoolPath, tempArgs));
|
|
container.FanSensors.Add(new ChromeboxECFanSensor(_config.EctoolPath, rpmArgs));
|
|
container.ControlSensors.Add(new ChromeboxECControlSensor(_config.EctoolPath, _config.AutoFanCtrlArgs));
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
_config = null;
|
|
_available = false;
|
|
}
|
|
}
|