Skip to content

Commit

Permalink
Move to liquidctl fork supporting interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Koli0842 committed Mar 26, 2023
1 parent ff4fd74 commit d55e3c8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 20 deletions.
Binary file removed LiquidCtlAfterburnerPlugin.7z
Binary file not shown.
56 changes: 45 additions & 11 deletions LiquidctlCLIWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
using System.Linq;
using System.Diagnostics;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace LiquidCtlAfterburnerPlugin
{
internal static class LiquidctlCLIWrapper
{
public static string liquidctlexe = $"{Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)}\\liquidctl.exe";
private static Dictionary<string, Process> liquidctlBackends = new Dictionary<string, Process>();

internal static void Initialize()
{
LiquidctlCall($"--json initialize all");
Expand All @@ -21,22 +24,38 @@ internal static List<LiquidctlStatusJSON> ReadStatus()
}
internal static List<LiquidctlStatusJSON> ReadStatus(string address)
{
Process process = LiquidctlCall($"--json --address {address} status");
return JsonConvert.DeserializeObject<List<LiquidctlStatusJSON>>(process.StandardOutput.ReadToEnd());
Process process = GetLiquidCtlBackend(address);
process.StandardInput.WriteLine("status");
JObject result = JObject.Parse(process.StandardOutput.ReadLine());
if ((string)result.SelectToken("status") == "success")
return result.SelectToken("data").ToObject<List<LiquidctlStatusJSON>>();
throw new Exception((string)result.SelectToken("data"));
}

private static Process LiquidctlCall(string arguments)
{
//File.AppendAllText(System.Reflection.Assembly.GetExecutingAssembly().Location + ".log", $"{DateTime.Now:s}: Invoking liquidctl\r\n");
Process process = new Process();
private static Process GetLiquidCtlBackend(string address) {
Process process = liquidctlBackends.ContainsKey(address) ? liquidctlBackends[address] : null;
if (process != null && !process.HasExited) {
return process;
}

process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
if (process != null) {
liquidctlBackends.Remove(address);
}

process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process = createLiquidCtlProcess();
process.StartInfo.Arguments = $"--json --address {address} interactive";

process.StartInfo.FileName = liquidctlexe;
liquidctlBackends.Add(address, process);

process.Start();

return process;
}

private static Process LiquidctlCall(string arguments)
{
//File.AppendAllText(System.Reflection.Assembly.GetExecutingAssembly().Location + ".log", $"{DateTime.Now:s}: Invoking liquidctl\r\n");
Process process = createLiquidCtlProcess();
process.StartInfo.Arguments = arguments;

process.Start();
Expand All @@ -49,5 +68,20 @@ private static Process LiquidctlCall(string arguments)

return process;
}

private static Process createLiquidCtlProcess() {
Process process = new Process();

process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;

process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardInput = true;

process.StartInfo.FileName = liquidctlexe;

return process;
}
}
}
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Libre Hardware Monitor Plugin for MSI Afterburner
# LiquidCTL Plugin for MSI Afterburner

This is a monitoring plugin for [MSI Afterburner](https://www.msi.com/Landing/afterburner) that exposes hardware monitoring data provided by [Libre Hardware Monitor](https://github.com/LiquidCtl/LiquidCtl) library.

You can use it to get motherboard temperatures, fan speeds, etc. that are not built-in to Afterburner and RTSS OSD without running external monitoring software.
This is a monitoring plugin for [MSI Afterburner](https://www.msi.com/Landing/afterburner) that exposes generic AIO data provided by [LiquidCtl](https://github.com/LiquidCtl/LiquidCtl).
Codebase is heavily inspired by https://github.com/ts-korhonen/LibreHardwareMonitorAfterburnerPlugin and https://github.com/SuspiciousActivity/FanControl.Liquidctl, given my lack of knowledge in the C# / Microsoft ecosystem, huge thanks to them.

## Requirements

Expand All @@ -11,27 +10,29 @@ You can use it to get motherboard temperatures, fan speeds, etc. that are not bu

## Installing

Download latest release of `LiquidCtl.dll` [here](https://github.com/ts-korhonen/LiquidCtlAfterburnerPlugin/releases) and place in into `Plugins/Monitoring` of MSI Afterburner installation folder.
Download latest release of `LiquidCtl.dll` [here](https://github.com/Koli0842/LiquidCtlAfterburnerPlugin/releases) and place in into `Plugins/Monitoring` of MSI Afterburner installation folder.

E.g. `C:\Program Files (x86)\MSI Afterburner\Plugins\Monitoring`
Download the latest release of [SuspiciousActivity's liquidctl fork](https://github.com/SuspiciousActivity/liquidctl) and place it next to the dll from the last step.

Plugin is standalone, it doesn't need Libre Hardware Monitor to be installed or running.
Additionally you need to put `Newtonsoft.Json.dll` into the root folder of MSI Afterburner.

E.g. `C:\Program Files (x86)\MSI Afterburner\Plugins\Monitoring`

## Setup

Start MSI Afterburner and go to `Settings > Monitoring` and click `[...]` button next to `Active hardware monitoring graphs`.

In the list of `Active plugin modules` select and activate the checkmark next to `LiquidCtl.dll`.

Click `Setup` to open plugin setup dialog where you can select which hardware and sensor types you want to monitor.
Setup button is disabled, current implementation exposes all hardware reported by LiquidCtl.

Afterburner should now be populated with discovered sensors.

## Uninstalling

Exit MSI Afterburner and delete `LiquidCtl.dll` you installed earlier.

In the same folder delete `LiquidCtl.sys` and `LiquidCtl.dll.log` if they exist.
In the same folder delete `LiquidCtl.dll.log` if they exist. You can clean up `Newtonsoft.Json.dll` aswell from the root folder aswell.

## License

Expand Down

0 comments on commit d55e3c8

Please sign in to comment.