New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

display-control

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

display-control - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

53

package.json
{
"name": "display-control",
"version": "0.0.2",
"description": "Sleep and wake the display",
"main": "src/index.js",
"files": [
"src"
],
"keywords": [
"turn",
"on",
"off",
"sleep",
"wake",
"display",
"screen",
"monitor",
"api",
"linux",
"darwin",
"mac",
"windows",
"win32"
],
"author": "SynergiTech (https://github.com/SynergiTech)",
"homepage": "https://github.com/SynergiTech/display-control",
"bugs": {
"url": "https://github.com/SynergiTech/display-control/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/SynergiTech/display-control.git"
},
"dependencies": {
"ffi": "^2.2.0",
"ref": "^1.3.5"
}
}
"name": "display-control",
"version": "0.1.0",
"description": "Sleep and wake the display",
"main": "src/index.js",
"files": ["src"],
"keywords": ["turn", "on", "off", "sleep", "wake", "display", "screen", "monitor", "api", "linux", "darwin", "mac", "windows", "win32"],
"author": "SynergiTech (https://github.com/SynergiTech)",
"homepage": "https://github.com/SynergiTech/display-control",
"bugs": {
"url": "https://github.com/SynergiTech/display-control/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/SynergiTech/display-control.git"
}
}

@@ -0,0 +0,0 @@ # display-control

@@ -1,8 +0,5 @@

"use strict";
const fs = require("fs");
const platform = require("os").platform();
var modulePath = __dirname + "/platforms/" + platform;
'use strict';
const fs = require('fs');
const platform = require('os').platform();
var modulePath = __dirname + '/platforms/' + platform;
if (fs.existsSync(modulePath + '.js')) {

@@ -18,2 +15,2 @@ module.exports = require(modulePath);

};
}
}

@@ -1,10 +0,7 @@

"use strict";
const execFile = require("child_process").execFile;
const os = require("os");
'use strict';
const execFile = require('child_process').execFile;
const os = require('os');
const darwin = {};
darwin.sleep = () => {
execFile("pmset", ["displaysleepnow"], (error, stdout, stderr) => {
execFile('pmset', ['displaysleepnow'], (error) => {
if (error) {

@@ -14,5 +11,5 @@ throw error;

});
}
};
darwin.wake = () => {
execFile("caffeinate", ["-u"], (error, stdout, stderr) => {
execFile('caffeinate', ['-u'], (error) => {
if (error) {

@@ -22,8 +19,6 @@ throw error;

});
}
};
darwin.supported = () => {
return os.platform() == 'darwin';
}
module.exports = darwin;
};
module.exports = darwin;

@@ -1,17 +0,14 @@

"use strict";
const exec = require("child_process").exec;
const os = require("os");
'use strict';
const exec = require('child_process').exec;
const os = require('os');
const linux = {};
linux.sleep = () => {
exec('export DISPLAY=:0; xset dpms force suspend');
}
};
linux.wake = () => {
exec('export DISPLAY=:0; xset dpms force on');
}
};
linux.supported = () => {
return os.platform() == 'linux';
}
module.exports = linux;
};
module.exports = linux;

@@ -1,59 +0,21 @@

"use strict";
const ffi = require("ffi");
const ref = require('ref');
const struct = require('ref-struct');
const os = require("os");
const HWND_BROADCAST = 0xffff;
const WM_SYSCOMMAND = 0x0112;
const SC_MONITORPOWER = 0xf170;
const POWER_OFF = 0x0002;
const POWER_ON = -0x0001;
'use strict';
const spawn = require('child_process').spawn;
const os = require('os');
const win32 = {};
const exec = function(cmd) {
return spawn(cmd, [], {
shell: true,
windowsHide: true
});
};
win32.sleep = () => {
var user32 = ffi.Library("user32", {
SendMessageW: ["int", ["ulong", "uint", "long", "long"]]
});
user32.SendMessageW(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, POWER_OFF);
}
exec('powershell -NonInteractive (Add-Type \'[DllImport(\\"user32.dll\\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);\' -Name a -Pas)::SendMessage(0xffff,0x0112,0xF170,0x0002)');
};
win32.wake = () => {
var sendMessageW = ffi.Library("user32", {
SendMessageW: ["int", ["ulong", "uint", "long", "long"]]
});
var MouseInput = struct({
'type': 'int',
'dx': 'long',
'dy': 'long',
'mouseData': 'int',
'dwFlags': 'int',
'time': 'int',
'dwExtraInfo': 'int'
})
var MouseInputPtr = ref.refType(MouseInput);
var mouseInput = new MouseInput();
mouseInput.type = 0;
mouseInput.dx = 0;
mouseInput.dy = 0;
mouseInput.dwFlags = 0x0002;
mouseInput.mouseData = 0;
mouseInput.time = 0;
mouseInput.dwExtraInfo = 0;
var sendInput = ffi.Library('user32', {
'SendInput': ['int', ['uint', MouseInputPtr, 'int']]
});
sendInput.SendInput(1, mouseInput.ref(), (os.arch() == 'x64' ? 40 : 28));
// sendInput.SendInput(1, mouseInput.ref(), 40);
sendMessageW.SendMessageW(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, POWER_ON);
}
exec('powershell -NonInteractive (Add-Type \'[DllImport(\\"user32.dll\\")]^public static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, int dwExtraInfo);\' -Name user32 -PassThru)::mouse_event(1,1,0,0,0)');
exec('powershell -NonInteractive (Add-Type \'[DllImport(\\"user32.dll\\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);\' -Name a -Pas)::SendMessage(0xffff,0x0112,0xF170,-0x0001)');
};
win32.supported = () => {
return os.platform == 'win32';
}
module.exports = win32;
};
module.exports = win32;

@@ -1,11 +0,8 @@

const displaycontrol = require(__dirname + "/index.js");
console.log("Supported: " + displaycontrol.supported());
const displaycontrol = require(__dirname + '/index.js');
console.log('Supported: ' + displaycontrol.supported());
console.log('Turning off');
displaycontrol.sleep();
setTimeout(function () {
setTimeout(function() {
console.log('Turning on');
displaycontrol.wake();
}, 10000)
}, 10000);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc