Skip to content

Commit

Permalink
Reverted to switching powerplans with powercfg.
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszCichecki committed Dec 6, 2021
1 parent d18f6cf commit 07b6f6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions LenovoLegionToolkit.Lib/Utils/Power.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ public class PowerPlan
public string Name { get; }
public bool IsActive { get; }

public string Guid
{
get
{
var guid = InstanceID.Split("\\").Last();
guid = guid.Replace("{", "").Replace("}", "");
return guid;
}
}

public PowerPlan(string instanceID, string name, bool isActive)
{
InstanceID = instanceID;
Expand Down Expand Up @@ -41,11 +51,7 @@ public static void ActivatePowerPlan(PowerModeState powerModeState)
if (powerPlan == null || powerPlan.IsActive)
return;

WMI.Invoke("root\\CIMV2\\power",
"Win32_PowerPlan",
"InstanceID",
powerPlan.InstanceID,
"Activate");
CMD.ExecuteProcess("powercfg", $"/s {powerPlan.Guid}");
}

private static PowerPlan Create(PropertyDataCollection properties)
Expand Down
4 changes: 2 additions & 2 deletions LenovoLegionToolkit.WPF/LenovoLegionToolkit.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
<AssemblyName>Lenovo Legion Toolkit</AssemblyName>
<Copyright>© 2021 Bartosz Cichecki</Copyright>
<FileVersion>1.5.1</FileVersion>
<Version>1.5.1</Version>
<FileVersion>1.5.2</FileVersion>
<Version>1.5.2</Version>
<Nullable>disable</Nullable>
<UseWPF>true</UseWPF>
<SelfContained>false</SelfContained>
Expand Down

0 comments on commit 07b6f6e

Please sign in to comment.