2019-02-08 17:46:58 +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:53:44 +00:00
|
|
|
//private
|
2019-06-09 01:43:14 +00:00
|
|
|
const exec_1 = require("exec");
|
2019-02-27 02:53:32 +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-02-27 02:53:32 +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-02-27 02:53:32 +00:00
|
|
|
**/
|
2019-03-23 00:29:36 +00:00
|
|
|
async function dependencies(platform) {
|
|
|
|
let obj = {};
|
2020-04-24 21:22:58 +00:00
|
|
|
let ffmpeg = require('ffmpeg-static');
|
|
|
|
let ffprobe = require('ffprobe-static');
|
2019-06-25 01:11:14 +00:00
|
|
|
let ffoutput;
|
2020-04-24 18:33:58 +00:00
|
|
|
//let imoutput : ExecOutput;
|
2019-06-25 01:11:14 +00:00
|
|
|
let eogoutput;
|
2020-04-25 02:12:56 +00:00
|
|
|
obj.ffmpeg = ffmpeg; /*.replace(
|
|
|
|
'app.asar',
|
|
|
|
'app.asar.unpacked'
|
|
|
|
);*/
|
|
|
|
obj.ffprobe = ffprobe.path; /*.replace(
|
|
|
|
'app.asar',
|
|
|
|
'app.asar.unpacked'
|
|
|
|
);*/
|
2019-06-24 15:37:07 +00:00
|
|
|
try {
|
2020-04-24 18:33:58 +00:00
|
|
|
//imoutput = await 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);
|
|
|
|
}
|
2020-04-24 18:33:58 +00:00
|
|
|
/*if (!imoutput || imoutput.stdout.trim() === '') {
|
2019-06-25 01:11:14 +00:00
|
|
|
console.error('imagemagick is not installed');
|
2020-04-24 18:33:58 +00:00
|
|
|
} else {
|
2019-06-25 01:11:14 +00:00
|
|
|
obj.convert = imoutput.stdout.trim();
|
2020-04-24 18:33:58 +00:00
|
|
|
}*/
|
2019-03-23 00:29:36 +00:00
|
|
|
//if linux
|
|
|
|
if (platform === 'nix') {
|
|
|
|
try {
|
2024-04-06 23:09:50 +00:00
|
|
|
eogoutput = await (0, 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;
|
|
|
|
}
|
|
|
|
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-02-08 17:46:58 +00:00
|
|
|
}
|
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:53:44 +00:00
|
|
|
}
|
2019-02-27 02:53:32 +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 {
|
2024-04-06 23:09:50 +00:00
|
|
|
obj.tmp = (0, os_1.tmpdir)();
|
2019-03-23 00:29:36 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
obj.tmp = '/tmp';
|
|
|
|
}
|
2024-04-06 23:09:50 +00:00
|
|
|
platform = (0, 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-02-08 17:46:58 +00:00
|
|
|
}
|
2019-03-23 00:29:36 +00:00
|
|
|
module.exports = system;
|
|
|
|
//# sourceMappingURL=index.js.map
|