mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 00:03:45 +00:00
Added battery detection for macOS
This commit is contained in:
@@ -296,6 +296,14 @@ module.exports.isBatteryPowered = function isBatteryOperated()
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'darwin':
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = ''; child.stdout.on('data', function(c){ this.str += c.toString(); });
|
||||
child.stderr.str = ''; child.stderr.on('data', function(c){ this.str += c.toString(); });
|
||||
child.stdin.write("pmset -g batt | tr '\\n' '`' | awk -F'`' '{ if(NF>2) { print \"true\"; }}'\nexit\n");
|
||||
child.waitExit();
|
||||
if(child.stdout.str.trim() != '') { ret = true; }
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user