mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-19 17:53:28 +00:00
added power-monitor.sleepDisplay() support to macOS
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -184,8 +184,10 @@ function powerMonitor()
|
||||
{
|
||||
var promise = require('promise');
|
||||
p = new promise(function (res, rej) { this._res = res; this._rej = rej; });
|
||||
if (process.platform != 'win32') { p._rej('Not supported'); return (p); }
|
||||
|
||||
switch (process.platform)
|
||||
{
|
||||
case 'win32':
|
||||
if (require('user-sessions').getProcessOwnerName(process.pid).tsid == 0)
|
||||
{
|
||||
// We are running as LocalSystem, so we have to find a user session for this to work
|
||||
@@ -213,6 +215,19 @@ function powerMonitor()
|
||||
p._res();
|
||||
if (require('child-container').child) { process._exit(); }
|
||||
}
|
||||
break;
|
||||
case 'darwin':
|
||||
p.child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
p.child.promise = p;
|
||||
p.child.stderr.on('data', function () { });
|
||||
p.child.stdout.on('data', function () { });
|
||||
p.child.on('exit', function () { this.promise._res(); });
|
||||
p.child.stdin.write('pmset displaysleepnow\nexit\n');
|
||||
break;
|
||||
default:
|
||||
p._rej('Not Supported');
|
||||
break;
|
||||
}
|
||||
return (p);
|
||||
};
|
||||
this.wakeDisplay = function wakeDisplay()
|
||||
|
||||
Reference in New Issue
Block a user