Skip to content

Commit

Permalink
Adding CPU temperature on trayicon
Browse files Browse the repository at this point in the history
  • Loading branch information
simonchen authored Nov 3, 2023
1 parent da16558 commit 0c1f42f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions DellFanManagementApp/DellFanManagementGuiForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,18 @@ public void UpdateForm()

// Temperatures.
int labelIndex = 0;
int cpu_count = 0;
int total_temperature = 0;
int avg_temperature = 0;
foreach (TemperatureComponent component in _state.Temperatures.Keys)
{
foreach (string key in _state.Temperatures[component].Keys)
{
if (key.IndexOf("CPU") >= 0)
{
cpu_count += 1;
total_temperature += _state.Temperatures[component][key];
}
string temperature = _state.Temperatures[component][key] != 0 ? _state.Temperatures[component][key].ToString() : "--";

string labelValue;
Expand Down Expand Up @@ -418,6 +426,7 @@ public void UpdateForm()
labelIndex++;
}
}
avg_temperature = total_temperature / cpu_count;

// EC fan control enabled?
if (_state.OperationMode != OperationMode.Manual)
Expand Down Expand Up @@ -517,11 +526,11 @@ public void UpdateForm()
// Tray icon hover text.
if (_state.Fan2Present)
{
trayIcon.Text = string.Format("Dell Fan Management\n{0}\n{1}", fan1RpmLabel.Text, fan2RpmLabel.Text);
trayIcon.Text = string.Format("Dell 风扇管理\nCPU: {0}\u00B0\n{1}\n{2}", avg_temperature, fan1RpmLabel.Text, fan2RpmLabel.Text);
}
else
{
trayIcon.Text = string.Format("Dell Fan Management\n{0}", fan1RpmLabel.Text);
trayIcon.Text = string.Format("Dell 风扇管理\nCPU: {0}\u00B0\n{1}", avg_temperature, fan1RpmLabel.Text);
}

UpdateTrayIcon(false);
Expand Down

0 comments on commit 0c1f42f

Please sign in to comment.