Hannah-Sten / TeXiFy-IDEA

LaTeX support for the IntelliJ platform by JetBrains.
https://hannah-sten.github.io/TeXiFy-IDEA
MIT License
894 stars 89 forks source link

Is it possible to add support for automatically disabling compilation when using battery mode on a laptop? #3631

Open hengzhe-zhang opened 2 months ago

hengzhe-zhang commented 2 months ago

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.

PHPirates commented 2 months ago

Uh, good question. Is it possible with code to check if your laptop is in battery mode?

hengzhe-zhang commented 2 months ago

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."
}