display-control
Advanced tools
Comparing version 0.0.2 to 0.1.0
{ | ||
"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); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
3420
75
4
- Removedffi@^2.2.0
- Removedref@^1.3.5
- Removedbindings@1.2.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removedffi@2.3.0(transitive)
- Removedms@2.0.0(transitive)
- Removednan@2.22.0(transitive)
- Removedref@1.3.5(transitive)
- Removedref-struct@1.1.0(transitive)