Specifically, I would like to make a GET request to a nodejs server, then get the number of monitors and their resolutions for the server.
E.g.
app.get('/screens', (req, res) => {
//return the screen info for the computer running this express server
})
CodePudding user response:
With systeminformation package.
...
const si = require('systeminformation')
app.get('/screens', async(req, res, next) => {
try {
const {
displays
} = await si.graphics()
if (!displays.length) {
throw new Error('No displays')
}
res.json({
displays: displays.length,
x: displays[0].currentResX,
y: displays[0].currentResY
})
} catch (err) {
next(err)
}
})
...
{ displays: 2, x: 1920, y: 1080 }