mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added option to stop all GPU apps before setting Eco
This commit is contained in:
59
app/Extra.Designer.cs
generated
59
app/Extra.Designer.cs
generated
@@ -51,6 +51,8 @@ namespace GHelper
|
|||||||
pictureHelp = new PictureBox();
|
pictureHelp = new PictureBox();
|
||||||
groupLight = new GroupBox();
|
groupLight = new GroupBox();
|
||||||
panelBacklightExtra = new Panel();
|
panelBacklightExtra = new Panel();
|
||||||
|
numericBacklightPluggedTime = new NumericUpDown();
|
||||||
|
labelBacklightTimeoutPlugged = new Label();
|
||||||
numericBacklightTime = new NumericUpDown();
|
numericBacklightTime = new NumericUpDown();
|
||||||
labelBacklightTimeout = new Label();
|
labelBacklightTimeout = new Label();
|
||||||
labelBrightness = new Label();
|
labelBrightness = new Label();
|
||||||
@@ -81,24 +83,23 @@ namespace GHelper
|
|||||||
checkSleepLid = new CheckBox();
|
checkSleepLid = new CheckBox();
|
||||||
checkShutdownLid = new CheckBox();
|
checkShutdownLid = new CheckBox();
|
||||||
groupOther = new GroupBox();
|
groupOther = new GroupBox();
|
||||||
|
checkGpuApps = new CheckBox();
|
||||||
checkAutoApplyWindowsPowerMode = new CheckBox();
|
checkAutoApplyWindowsPowerMode = new CheckBox();
|
||||||
checkKeyboardAuto = new CheckBox();
|
checkKeyboardAuto = new CheckBox();
|
||||||
checkUSBC = new CheckBox();
|
checkUSBC = new CheckBox();
|
||||||
checkNoOverdrive = new CheckBox();
|
checkNoOverdrive = new CheckBox();
|
||||||
checkTopmost = new CheckBox();
|
checkTopmost = new CheckBox();
|
||||||
numericBacklightPluggedTime = new NumericUpDown();
|
|
||||||
labelBacklightTimeoutPlugged = new Label();
|
|
||||||
groupBindings.SuspendLayout();
|
groupBindings.SuspendLayout();
|
||||||
tableKeys.SuspendLayout();
|
tableKeys.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureHelp).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureHelp).BeginInit();
|
||||||
groupLight.SuspendLayout();
|
groupLight.SuspendLayout();
|
||||||
panelBacklightExtra.SuspendLayout();
|
panelBacklightExtra.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericBacklightPluggedTime).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericBacklightTime).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericBacklightTime).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)trackBrightness).BeginInit();
|
((System.ComponentModel.ISupportInitialize)trackBrightness).BeginInit();
|
||||||
panelXMG.SuspendLayout();
|
panelXMG.SuspendLayout();
|
||||||
tableBacklight.SuspendLayout();
|
tableBacklight.SuspendLayout();
|
||||||
groupOther.SuspendLayout();
|
groupOther.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)numericBacklightPluggedTime).BeginInit();
|
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBindings
|
// groupBindings
|
||||||
@@ -326,6 +327,22 @@ namespace GHelper
|
|||||||
panelBacklightExtra.Size = new Size(948, 241);
|
panelBacklightExtra.Size = new Size(948, 241);
|
||||||
panelBacklightExtra.TabIndex = 43;
|
panelBacklightExtra.TabIndex = 43;
|
||||||
//
|
//
|
||||||
|
// numericBacklightPluggedTime
|
||||||
|
//
|
||||||
|
numericBacklightPluggedTime.Location = new Point(655, 181);
|
||||||
|
numericBacklightPluggedTime.Maximum = new decimal(new int[] { 3600, 0, 0, 0 });
|
||||||
|
numericBacklightPluggedTime.Name = "numericBacklightPluggedTime";
|
||||||
|
numericBacklightPluggedTime.Size = new Size(240, 39);
|
||||||
|
numericBacklightPluggedTime.TabIndex = 49;
|
||||||
|
//
|
||||||
|
// labelBacklightTimeoutPlugged
|
||||||
|
//
|
||||||
|
labelBacklightTimeoutPlugged.Location = new Point(13, 183);
|
||||||
|
labelBacklightTimeoutPlugged.Name = "labelBacklightTimeoutPlugged";
|
||||||
|
labelBacklightTimeoutPlugged.Size = new Size(636, 45);
|
||||||
|
labelBacklightTimeoutPlugged.TabIndex = 48;
|
||||||
|
labelBacklightTimeoutPlugged.Text = "Seconds to turn off backlight when plugged";
|
||||||
|
//
|
||||||
// numericBacklightTime
|
// numericBacklightTime
|
||||||
//
|
//
|
||||||
numericBacklightTime.Location = new Point(655, 133);
|
numericBacklightTime.Location = new Point(655, 133);
|
||||||
@@ -667,6 +684,7 @@ namespace GHelper
|
|||||||
//
|
//
|
||||||
// groupOther
|
// groupOther
|
||||||
//
|
//
|
||||||
|
groupOther.Controls.Add(checkGpuApps);
|
||||||
groupOther.Controls.Add(checkAutoApplyWindowsPowerMode);
|
groupOther.Controls.Add(checkAutoApplyWindowsPowerMode);
|
||||||
groupOther.Controls.Add(checkKeyboardAuto);
|
groupOther.Controls.Add(checkKeyboardAuto);
|
||||||
groupOther.Controls.Add(checkUSBC);
|
groupOther.Controls.Add(checkUSBC);
|
||||||
@@ -675,15 +693,25 @@ namespace GHelper
|
|||||||
groupOther.Dock = DockStyle.Top;
|
groupOther.Dock = DockStyle.Top;
|
||||||
groupOther.Location = new Point(10, 897);
|
groupOther.Location = new Point(10, 897);
|
||||||
groupOther.Name = "groupOther";
|
groupOther.Name = "groupOther";
|
||||||
groupOther.Size = new Size(954, 276);
|
groupOther.Size = new Size(954, 310);
|
||||||
groupOther.TabIndex = 2;
|
groupOther.TabIndex = 2;
|
||||||
groupOther.TabStop = false;
|
groupOther.TabStop = false;
|
||||||
groupOther.Text = "Other";
|
groupOther.Text = "Other";
|
||||||
//
|
//
|
||||||
|
// checkGpuApps
|
||||||
|
//
|
||||||
|
checkGpuApps.AutoSize = true;
|
||||||
|
checkGpuApps.Location = new Point(25, 220);
|
||||||
|
checkGpuApps.Name = "checkGpuApps";
|
||||||
|
checkGpuApps.Size = new Size(544, 36);
|
||||||
|
checkGpuApps.TabIndex = 48;
|
||||||
|
checkGpuApps.Text = "Stop all apps using GPU when switching to Eco";
|
||||||
|
checkGpuApps.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// checkAutoApplyWindowsPowerMode
|
// checkAutoApplyWindowsPowerMode
|
||||||
//
|
//
|
||||||
checkAutoApplyWindowsPowerMode.AutoSize = true;
|
checkAutoApplyWindowsPowerMode.AutoSize = true;
|
||||||
checkAutoApplyWindowsPowerMode.Location = new Point(25, 220);
|
checkAutoApplyWindowsPowerMode.Location = new Point(25, 268);
|
||||||
checkAutoApplyWindowsPowerMode.Name = "checkAutoApplyWindowsPowerMode";
|
checkAutoApplyWindowsPowerMode.Name = "checkAutoApplyWindowsPowerMode";
|
||||||
checkAutoApplyWindowsPowerMode.Size = new Size(416, 36);
|
checkAutoApplyWindowsPowerMode.Size = new Size(416, 36);
|
||||||
checkAutoApplyWindowsPowerMode.TabIndex = 47;
|
checkAutoApplyWindowsPowerMode.TabIndex = 47;
|
||||||
@@ -731,29 +759,13 @@ namespace GHelper
|
|||||||
checkTopmost.Text = Strings.WindowTop;
|
checkTopmost.Text = Strings.WindowTop;
|
||||||
checkTopmost.UseVisualStyleBackColor = true;
|
checkTopmost.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// numericBacklightPluggedTime
|
|
||||||
//
|
|
||||||
numericBacklightPluggedTime.Location = new Point(655, 181);
|
|
||||||
numericBacklightPluggedTime.Maximum = new decimal(new int[] { 3600, 0, 0, 0 });
|
|
||||||
numericBacklightPluggedTime.Name = "numericBacklightPluggedTime";
|
|
||||||
numericBacklightPluggedTime.Size = new Size(240, 39);
|
|
||||||
numericBacklightPluggedTime.TabIndex = 49;
|
|
||||||
//
|
|
||||||
// labelBacklightTimeoutPlugged
|
|
||||||
//
|
|
||||||
labelBacklightTimeoutPlugged.Location = new Point(13, 183);
|
|
||||||
labelBacklightTimeoutPlugged.Name = "labelBacklightTimeoutPlugged";
|
|
||||||
labelBacklightTimeoutPlugged.Size = new Size(636, 45);
|
|
||||||
labelBacklightTimeoutPlugged.TabIndex = 48;
|
|
||||||
labelBacklightTimeoutPlugged.Text = "Seconds to turn off backlight when plugged";
|
|
||||||
//
|
|
||||||
// Extra
|
// Extra
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
AutoSize = true;
|
AutoSize = true;
|
||||||
AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
ClientSize = new Size(974, 1131);
|
ClientSize = new Size(974, 1220);
|
||||||
Controls.Add(groupOther);
|
Controls.Add(groupOther);
|
||||||
Controls.Add(groupLight);
|
Controls.Add(groupLight);
|
||||||
Controls.Add(groupBindings);
|
Controls.Add(groupBindings);
|
||||||
@@ -775,6 +787,7 @@ namespace GHelper
|
|||||||
groupLight.PerformLayout();
|
groupLight.PerformLayout();
|
||||||
panelBacklightExtra.ResumeLayout(false);
|
panelBacklightExtra.ResumeLayout(false);
|
||||||
panelBacklightExtra.PerformLayout();
|
panelBacklightExtra.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericBacklightPluggedTime).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericBacklightTime).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericBacklightTime).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)trackBrightness).EndInit();
|
((System.ComponentModel.ISupportInitialize)trackBrightness).EndInit();
|
||||||
panelXMG.ResumeLayout(false);
|
panelXMG.ResumeLayout(false);
|
||||||
@@ -782,7 +795,6 @@ namespace GHelper
|
|||||||
tableBacklight.ResumeLayout(false);
|
tableBacklight.ResumeLayout(false);
|
||||||
groupOther.ResumeLayout(false);
|
groupOther.ResumeLayout(false);
|
||||||
groupOther.PerformLayout();
|
groupOther.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)numericBacklightPluggedTime).EndInit();
|
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@@ -846,5 +858,6 @@ namespace GHelper
|
|||||||
private TextBox textM1;
|
private TextBox textM1;
|
||||||
private NumericUpDown numericBacklightPluggedTime;
|
private NumericUpDown numericBacklightPluggedTime;
|
||||||
private Label labelBacklightTimeoutPlugged;
|
private Label labelBacklightTimeoutPlugged;
|
||||||
|
private CheckBox checkGpuApps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
10
app/Extra.cs
10
app/Extra.cs
@@ -99,6 +99,8 @@ namespace GHelper
|
|||||||
labelBacklightLid.Text = Properties.Strings.Lid;
|
labelBacklightLid.Text = Properties.Strings.Lid;
|
||||||
labelBacklightLogo.Text = Properties.Strings.Logo;
|
labelBacklightLogo.Text = Properties.Strings.Logo;
|
||||||
|
|
||||||
|
checkGpuApps.Text = Properties.Strings.KillGpuApps;
|
||||||
|
|
||||||
Text = Properties.Strings.ExtraSettings;
|
Text = Properties.Strings.ExtraSettings;
|
||||||
|
|
||||||
InitTheme();
|
InitTheme();
|
||||||
@@ -217,6 +219,14 @@ namespace GHelper
|
|||||||
numericBacklightTime.ValueChanged += NumericBacklightTime_ValueChanged;
|
numericBacklightTime.ValueChanged += NumericBacklightTime_ValueChanged;
|
||||||
numericBacklightPluggedTime.ValueChanged += NumericBacklightTime_ValueChanged;
|
numericBacklightPluggedTime.ValueChanged += NumericBacklightTime_ValueChanged;
|
||||||
|
|
||||||
|
checkGpuApps.Checked = AppConfig.isConfig("kill_gpu_apps");
|
||||||
|
checkGpuApps.CheckedChanged += CheckGpuApps_CheckedChanged;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckGpuApps_CheckedChanged(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
AppConfig.setConfig("kill_gpu_apps", (checkGpuApps.Checked ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NumericBacklightTime_ValueChanged(object? sender, EventArgs e)
|
private void NumericBacklightTime_ValueChanged(object? sender, EventArgs e)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NvAPIWrapper.GPU;
|
using NvAPIWrapper;
|
||||||
|
using NvAPIWrapper.GPU;
|
||||||
using NvAPIWrapper.Native;
|
using NvAPIWrapper.Native;
|
||||||
using NvAPIWrapper.Native.Delegates;
|
using NvAPIWrapper.Native.Delegates;
|
||||||
using NvAPIWrapper.Native.GPU;
|
using NvAPIWrapper.Native.GPU;
|
||||||
@@ -35,8 +36,7 @@ public class NvidiaGpuControl : IGpuControl
|
|||||||
|
|
||||||
public int? GetCurrentTemperature()
|
public int? GetCurrentTemperature()
|
||||||
{
|
{
|
||||||
if (!IsValid)
|
if (!IsValid) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
PhysicalGPU internalGpu = _internalGpu!;
|
PhysicalGPU internalGpu = _internalGpu!;
|
||||||
IThermalSensor? gpuSensor =
|
IThermalSensor? gpuSensor =
|
||||||
@@ -50,6 +50,38 @@ public class NvidiaGpuControl : IGpuControl
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void KillGPUApps()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!IsValid) return;
|
||||||
|
PhysicalGPU internalGpu = _internalGpu!;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process[] processes = internalGpu.GetActiveApplications();
|
||||||
|
foreach (Process process in processes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
process?.Kill();
|
||||||
|
Logger.WriteLine("Stopped: " + process.ProcessName);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//NVIDIA.RestartDisplayDriver();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public int GetClocks(out int core, out int memory)
|
public int GetClocks(out int core, out int memory)
|
||||||
{
|
{
|
||||||
|
|||||||
9
app/Properties/Strings.Designer.cs
generated
9
app/Properties/Strings.Designer.cs
generated
@@ -627,6 +627,15 @@ namespace GHelper.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Stop all apps using GPU when switching to Eco.
|
||||||
|
/// </summary>
|
||||||
|
internal static string KillGpuApps {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("KillGpuApps", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Laptop Backlight.
|
/// Looks up a localized string similar to Laptop Backlight.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -306,6 +306,9 @@
|
|||||||
<data name="KeyboardAuto" xml:space="preserve">
|
<data name="KeyboardAuto" xml:space="preserve">
|
||||||
<value>Lower backlight brightness on battery and back when plugged</value>
|
<value>Lower backlight brightness on battery and back when plugged</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="KillGpuApps" xml:space="preserve">
|
||||||
|
<value>Stop all apps using GPU when switching to Eco</value>
|
||||||
|
</data>
|
||||||
<data name="LaptopBacklight" xml:space="preserve">
|
<data name="LaptopBacklight" xml:space="preserve">
|
||||||
<value>Laptop Backlight</value>
|
<value>Laptop Backlight</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Net;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
using System.Windows.Forms;
|
||||||
using Tools;
|
using Tools;
|
||||||
|
|
||||||
namespace GHelper
|
namespace GHelper
|
||||||
@@ -1478,9 +1479,15 @@ namespace GHelper
|
|||||||
protected static void KillGPUApps()
|
protected static void KillGPUApps()
|
||||||
{
|
{
|
||||||
string[] tokill = { "EADesktop", "RadeonSoftware", "epicgameslauncher" };
|
string[] tokill = { "EADesktop", "RadeonSoftware", "epicgameslauncher" };
|
||||||
|
|
||||||
foreach (string kill in tokill)
|
foreach (string kill in tokill)
|
||||||
foreach (var process in Process.GetProcessesByName(kill)) process.Kill();
|
foreach (var process in Process.GetProcessesByName(kill)) process.Kill();
|
||||||
|
|
||||||
|
if (AppConfig.isConfig("kill_gpu_apps") && HardwareControl.GpuControl is not null && HardwareControl.GpuControl.IsNvidia)
|
||||||
|
{
|
||||||
|
NvidiaGpuControl nvControl = (NvidiaGpuControl)HardwareControl.GpuControl;
|
||||||
|
nvControl.KillGPUApps();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetGPUEco(int eco, bool hardWay = false)
|
public void SetGPUEco(int eco, bool hardWay = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user