mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
System Startup charge limiter
This commit is contained in:
@@ -53,6 +53,13 @@ namespace GHelper
|
||||
string action = "";
|
||||
if (args.Length > 0) action = args[0];
|
||||
|
||||
if (action == "charge")
|
||||
{
|
||||
BatteryLimit();
|
||||
Application.Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
string language = AppConfig.GetString("language");
|
||||
|
||||
if (language != null && language.Length > 0)
|
||||
@@ -205,7 +212,7 @@ namespace GHelper
|
||||
if (settingsForm.matrixForm is not null && settingsForm.matrixForm.Text != "")
|
||||
settingsForm.matrixForm.InitTheme();
|
||||
|
||||
if (settingsForm.handheldForm is not null && settingsForm.handheldForm.Text != "")
|
||||
if (settingsForm.handheldForm is not null && settingsForm.handheldForm.Text != "")
|
||||
settingsForm.handheldForm.InitTheme();
|
||||
|
||||
break;
|
||||
@@ -243,7 +250,8 @@ namespace GHelper
|
||||
if (AppConfig.IsAlly())
|
||||
{
|
||||
allyControl.Init();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsForm.AutoKeyboard();
|
||||
}
|
||||
@@ -288,7 +296,7 @@ namespace GHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
var screen = Screen.PrimaryScreen;
|
||||
var screen = Screen.PrimaryScreen;
|
||||
if (screen is null) screen = Screen.FromControl(settingsForm);
|
||||
|
||||
settingsForm.Location = screen.WorkingArea.Location;
|
||||
@@ -299,7 +307,7 @@ namespace GHelper
|
||||
settingsForm.Activate();
|
||||
|
||||
settingsForm.Left = screen.WorkingArea.Width - 10 - settingsForm.Width;
|
||||
|
||||
|
||||
if (AppConfig.IsAlly())
|
||||
settingsForm.Top = Math.Max(10, screen.Bounds.Height - 110 - settingsForm.Height);
|
||||
else
|
||||
@@ -328,6 +336,23 @@ namespace GHelper
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
static void BatteryLimit()
|
||||
{
|
||||
try
|
||||
{
|
||||
int limit = 80;
|
||||
if (limit > 0 && limit < 100)
|
||||
{
|
||||
Logger.WriteLine($"Startup Battery Limit {limit}");
|
||||
acpi = new AsusACPI(true);
|
||||
acpi.DeviceSet(AsusACPI.BatteryLimit, limit, "Limit");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine("Startup Battery Limit Error: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user