Open hengzhe-zhang opened 2 months ago
Uh, good question. Is it possible with code to check if your laptop is in battery mode?
Yes, it is possible to check whether the laptop is running on battery power using code, at least on Windows, by utilizing the following PowerShell script:
$powerStatus = Get-WmiObject -Query "SELECT * FROM Win32_Battery"
if ($powerStatus.BatteryStatus -eq 1) {
Write-Output "Laptop is running on battery."
} else {
Write-Output "Laptop is plugged in."
}
Is it possible to add support for automatically disabling compilation when using battery mode on a laptop? I've noticed that with automatic compilation enabled, CPU usage is very high, and I frequently need to manually disable it to reduce battery consumption.