mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-20 18:23:21 +00:00
Added battery detection for macOS
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -296,6 +296,14 @@ module.exports.isBatteryPowered = function isBatteryOperated()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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);
|
return (ret);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user