bug fix (battery - windows)
This commit is contained in:
parent
ed3763cba9
commit
ccd8a17fd1
@ -98,6 +98,7 @@ Other changes
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 3.23.2 | 2017-06-23 | bug fix `battery` (windows) |
|
||||||
| 3.23.1 | 2017-06-22 | updated docs |
|
| 3.23.1 | 2017-06-22 | updated docs |
|
||||||
| 3.23.0 | 2017-06-22 | added `memLayout`, `diskLayout`, extended windows support (`inetChecksite`)|
|
| 3.23.0 | 2017-06-22 | added `memLayout`, `diskLayout`, extended windows support (`inetChecksite`)|
|
||||||
| 3.22.0 | 2017-06-19 | extended windows support (`users`, `inetLatency`) |
|
| 3.22.0 | 2017-06-19 | extended windows support (`users`, `inetLatency`) |
|
||||||
|
|||||||
@ -10,7 +10,7 @@ Simple system and OS information library for [node.js][nodejs-url]
|
|||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
Collection of 30+ functions to retrieve detailed hardware, system and OS information (Linux, OSX and now partial Windows support)
|
Collection of 35+ functions to retrieve detailed hardware, system and OS information (Linux, OSX and partial Windows support)
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
|||||||
| | serial | X | X | X | serial number |
|
| | serial | X | X | X | serial number |
|
||||||
| | uuid | X | X | X | UUID |
|
| | uuid | X | X | X | UUID |
|
||||||
|
|
||||||
#### 3. CPU, Memory, Battery, Graphics
|
#### 3. CPU, Memory, Disks, Battery, Graphics
|
||||||
|
|
||||||
| Function | Result object | Linux | OSX | Win | Comments |
|
| Function | Result object | Linux | OSX | Win | Comments |
|
||||||
| --------------- | ----- | ----- | ---- | ------- | -------- |
|
| --------------- | ----- | ----- | ---- | ------- | -------- |
|
||||||
|
|||||||
@ -117,14 +117,17 @@ module.exports = function (callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec("WMIC Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value", function (error, stdout) {
|
exec("WMIC Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value", function (error, stdout) {
|
||||||
if (!error) {
|
if (stdout) {
|
||||||
let lines = stdout.split('\r\n');
|
let lines = stdout.split('\r\n');
|
||||||
let status = parseInt(getValue(lines, 'BatteryStatus', '=') || '2');
|
let status = getValue(lines, 'BatteryStatus', '=').trim();
|
||||||
result.hasbattery = true;
|
if (status) {
|
||||||
result.maxcapacity = parseInt(getValue(lines, 'DesignCapacity', '=') || 0);
|
status = parseInt(status || '2');
|
||||||
result.percent = parseInt(getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
|
result.hasbattery = true;
|
||||||
result.currentcapacity = parseInt(result.maxcapacity * result.percent / 100);
|
result.maxcapacity = parseInt(getValue(lines, 'DesignCapacity', '=') || 0);
|
||||||
result.ischarging = (status >= 6 && status <= 9) || (!(status === 3) && !(status === 1) && result.percent < 100);
|
result.percent = parseInt(getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
|
||||||
|
result.currentcapacity = parseInt(result.maxcapacity * result.percent / 100);
|
||||||
|
result.ischarging = (status >= 6 && status <= 9) || (!(status === 3) && !(status === 1) && result.percent < 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (callback) { callback(result) }
|
if (callback) { callback(result) }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user