2019-03-22 23:52:59 +00:00
|
|
|
'use strict';
|
2019-03-23 00:29:36 +00:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2019-06-09 01:43:14 +00:00
|
|
|
const os_1 = require("os");
|
2019-06-22 15:52:36 +00:00
|
|
|
const electron_1 = require("electron");
|
2019-03-22 23:52:59 +00:00
|
|
|
//private
|
2019-06-09 01:43:14 +00:00
|
|
|
const exec_1 = require("exec");
|
2019-03-22 23:52:59 +00:00
|
|
|
/**
|
|
|
|
* Evaluates system dependencies for digital
|
2019-07-26 22:31:22 +00:00
|
|
|
* projector features by executing `which` on binary.
|
|
|
|
* If they do not exist, log to console
|
2019-03-23 00:29:36 +00:00
|
|
|
*
|
2019-03-22 23:52:59 +00:00
|
|
|
* @param {string} platform Operating system type
|
2019-07-26 22:12:06 +00:00
|
|
|
*
|
|
|
|
* @returns {object} Object containing path to dependency from `which`, if they exist
|
2019-03-22 23:52:59 +00:00
|
|
|
**/
|
2019-03-23 00:29:36 +00:00
|
|
|
async function dependencies(platform) {
|
|
|
|
let obj = {};
|
2019-08-23 19:39:38 +00:00
|
|
|
let ffmpeg = require('ffmpeg-static');
|
2019-06-25 01:11:14 +00:00
|
|
|
let ffoutput;
|
|
|
|
let imoutput;
|
|
|
|
let eogoutput;
|
2020-01-19 05:36:58 +00:00
|
|
|
obj.ffmpeg = ffmpeg;
|
2019-06-24 15:37:07 +00:00
|
|
|
try {
|
2019-06-25 01:11:14 +00:00
|
|
|
imoutput = await exec_1.exec('which convert');
|
2019-06-24 15:37:07 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
2019-06-25 01:11:14 +00:00
|
|
|
console.error('imagemagick is not installed', err);
|
|
|
|
}
|
|
|
|
if (!imoutput || imoutput.stdout.trim() === '') {
|
|
|
|
console.error('imagemagick is not installed');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
obj.convert = imoutput.stdout.trim();
|
2019-06-24 15:37:07 +00:00
|
|
|
}
|
2019-03-23 00:29:36 +00:00
|
|
|
//if linux
|
|
|
|
if (platform === 'nix') {
|
|
|
|
try {
|
2019-06-25 01:11:14 +00:00
|
|
|
eogoutput = await exec_1.exec('which eog');
|
2019-03-23 00:29:36 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
2019-06-25 01:11:14 +00:00
|
|
|
console.error('eog is not installed', err);
|
|
|
|
}
|
|
|
|
if (!eogoutput || eogoutput.stdout.trim() === '') {
|
|
|
|
console.error('eog is not installed');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
obj.eog = eogoutput.stdout.trim();
|
2019-03-23 00:29:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return obj;
|
2019-03-22 23:52:59 +00:00
|
|
|
}
|
2019-03-23 00:29:36 +00:00
|
|
|
function displayMap(obj) {
|
|
|
|
const sm = {
|
2019-06-25 01:11:14 +00:00
|
|
|
id: obj.id,
|
2019-06-24 15:26:28 +00:00
|
|
|
width: obj.size.width,
|
|
|
|
height: obj.size.height,
|
|
|
|
x: obj.bounds.x,
|
|
|
|
y: obj.bounds.y,
|
|
|
|
scale: obj.scaleFactor,
|
|
|
|
primary: (obj.bounds.x === 0 && obj.bounds.y === 0)
|
2019-03-23 00:29:36 +00:00
|
|
|
};
|
2019-06-24 15:26:28 +00:00
|
|
|
const primary = sm.primary ? ' (Primary)' : '';
|
|
|
|
sm.name = `${sm.width}x${sm.height}${primary}`;
|
2019-03-23 00:29:36 +00:00
|
|
|
return sm;
|
|
|
|
}
|
2019-06-24 15:26:28 +00:00
|
|
|
function displaySort(a, b) {
|
|
|
|
if (a.primary) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (b.primary) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2019-03-23 00:29:36 +00:00
|
|
|
async function displays() {
|
2019-06-24 15:26:28 +00:00
|
|
|
let displays = electron_1.screen.getAllDisplays();
|
|
|
|
displays = displays.map(displayMap);
|
|
|
|
displays.sort(displaySort);
|
|
|
|
return displays;
|
2019-03-22 23:52:59 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Profile the current system and return an object with
|
|
|
|
* data about the displays and dependencies for the digital
|
|
|
|
* projector feature.
|
|
|
|
*
|
|
|
|
* @returns {object} Object containing system information
|
2019-03-23 00:29:36 +00:00
|
|
|
*/
|
2019-06-24 16:42:27 +00:00
|
|
|
async function system(ui) {
|
2019-03-23 00:29:36 +00:00
|
|
|
const obj = {};
|
|
|
|
let platform;
|
|
|
|
try {
|
2019-06-09 01:43:14 +00:00
|
|
|
obj.tmp = os_1.tmpdir();
|
2019-03-23 00:29:36 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
obj.tmp = '/tmp';
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
platform = os_1.type();
|
2019-03-23 00:29:36 +00:00
|
|
|
if (platform === 'Darwin') {
|
|
|
|
obj.platform = 'osx';
|
|
|
|
}
|
|
|
|
else if (platform === 'Windows_NT') {
|
|
|
|
obj.platform = 'win';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
obj.platform = 'nix';
|
|
|
|
}
|
|
|
|
obj.displays = await displays();
|
|
|
|
obj.deps = await dependencies(obj.platform);
|
2019-06-25 01:11:14 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
ui.send('system', obj);
|
|
|
|
}, 3000);
|
2019-03-23 00:29:36 +00:00
|
|
|
return obj;
|
2019-03-22 23:52:59 +00:00
|
|
|
}
|
2019-03-23 00:29:36 +00:00
|
|
|
module.exports = system;
|
|
|
|
//# sourceMappingURL=index.js.map
|