View Single Post
  #6  
Old 19.09.2021, 14:21
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,371
Default

Quote:
Originally Posted by amn87 View Post
I found this command to get the battery percentage "WMIC PATH Win32_Battery Get EstimatedChargeRemaining".
Solved via IRC:
Code:
/*
    Stop downloads when battery low (Windows OS)
    Trigger : Interval
    Recommended Interval 60000 (1 min)
*/

var target = 20;

if (isDownloadControllerRunning()) {
    try {
        var result = callSync("WMIC", "PATH", "Win32_Battery", "Get", "EstimatedChargeRemaining");
        var remaining = result.match(/EstimatedChargeRemaining  \r\r\n(\d+)                        \r\r\n\r\r\n/)[1];

        remaining < target && stopDownloads();
    } catch (e) {};
}
Reply With Quote