Skip to content

Commit

Permalink
Status LED automation #3354
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Nov 11, 2024
1 parent dea88f8 commit 2f2d641
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -713,5 +713,10 @@ public static bool SaveDimming()
return Is("save_dimming");
}

public static bool IsAutoStatusLed()
{
return Is("auto_status_led");
}


}
2 changes: 1 addition & 1 deletion app/Extra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ private void CheckPerKeyRGB_CheckedChanged(object? sender, EventArgs e)

private void CheckLEDStatus_CheckedChanged(object? sender, EventArgs e)
{
Program.acpi.DeviceSet(AsusACPI.StatusLed, (checkStatusLed.Checked ? 7 : 0), "StatusLED");
InputDispatcher.SetStatusLED(checkStatusLed.Checked);
}

private void CheckBWIcon_CheckedChanged(object? sender, EventArgs e)
Expand Down
15 changes: 15 additions & 0 deletions app/Input/InputDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,21 @@ public static void InitScreenpad()
if (brightness >= 0) ApplyScreenpadAction(brightness);
}

public static void SetStatusLED(bool status)
{
Program.acpi.DeviceSet(AsusACPI.StatusLed, status ? 7 : 0, "StatusLED");
}

public static void InitStatusLed()
{
if (AppConfig.IsAutoStatusLed()) SetStatusLED(true);
}

public static void ShutdownStatusLed()
{
if (AppConfig.IsAutoStatusLed()) SetStatusLED(false);
}

static void LaunchProcess(string command = "")
{
if (string.IsNullOrEmpty(command)) return;
Expand Down
3 changes: 3 additions & 0 deletions app/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ private static void SystemEvents_SessionEnding(object sender, SessionEndingEvent
{
gpuControl.StandardModeFix();
BatteryControl.AutoBattery();
InputDispatcher.ShutdownStatusLed();
}

private static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
Expand Down Expand Up @@ -237,6 +238,7 @@ public static bool SetAutoModes(bool powerChanged = false, bool init = false)
{
screenControl.InitMiniled();
InputDispatcher.InitScreenpad();
InputDispatcher.InitStatusLed();
}

inputDispatcher.Init();
Expand Down Expand Up @@ -275,6 +277,7 @@ private static void SystemEvents_PowerModeChanged(object sender, PowerModeChange
{
Logger.WriteLine("Power Mode Changed:" + e.Mode.ToString());
gpuControl.StandardModeFix();
InputDispatcher.ShutdownStatusLed();
}

int delay = AppConfig.Get("charger_delay");
Expand Down

0 comments on commit 2f2d641

Please sign in to comment.