graphics() raspberry ubuntu displays

This commit is contained in:
Sebastian Hildebrandt 2025-01-10 21:50:34 +01:00
parent 36379825c3
commit e8deda9fd3
2 changed files with 33 additions and 29 deletions

View File

@ -48,9 +48,9 @@ add new features and support more platforms. Thank you in advance!
## Node.js ✅, Bun ✅ and Deno ✅
I tested this library with Node.js, Bun and Deno (V2.x) with no issues. There is
currently only one problem on Denos side: os.freemem() pollyfill is currently
not correct (version 2.1.4) but there is already a fix (not yet published).
I tested this library with Node.js, Bun and Deno (V2.x) with no issues. There
was only one problem on Denos side in version <= 2.1.4: os.freemem() pollyfill
was not correct but this is now fixed with Deno >= 2.1.5.
**Attention**: This library is supposed to be used as a backend/server-side
library and **will definitely not work within a browser**.

View File

@ -768,51 +768,55 @@ function graphics(callback) {
vramDynamic: true
});
}
if (callback) {
callback(result);
}
resolve(result);
// if (callback) {
// callback(result);
// }
// resolve(result);
});
} else {
let cmd = 'lspci -vvv 2>/dev/null';
exec(cmd, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
}
// } else {
let cmd = 'lspci -vvv 2>/dev/null';
exec(cmd, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
if (result.controllers.length === 0) {
result.controllers = parseLinesLinuxControllers(lines);
const nvidiaData = nvidiaDevices();
// needs to be rewritten ... using no spread operators
result.controllers = result.controllers.map((controller) => { // match by busAddress
return mergeControllerNvidia(controller, nvidiaData.find((contr) => contr.pciBus.toLowerCase().endsWith(controller.busAddress.toLowerCase())) || {});
});
}
let cmd = 'clinfo --raw';
}
let cmd = 'clinfo --raw';
exec(cmd, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
result.controllers = parseLinesLinuxClinfo(result.controllers, lines);
}
let cmd = 'xdpyinfo 2>/dev/null | grep \'depth of root window\' | awk \'{ print $5 }\'';
exec(cmd, function (error, stdout) {
let depth = 0;
if (!error) {
let lines = stdout.toString().split('\n');
result.controllers = parseLinesLinuxClinfo(result.controllers, lines);
depth = parseInt(lines[0]) || 0;
}
let cmd = 'xdpyinfo 2>/dev/null | grep \'depth of root window\' | awk \'{ print $5 }\'';
let cmd = 'xrandr --verbose 2>/dev/null';
exec(cmd, function (error, stdout) {
let depth = 0;
if (!error) {
let lines = stdout.toString().split('\n');
depth = parseInt(lines[0]) || 0;
result.displays = parseLinesLinuxDisplays(lines, depth);
}
let cmd = 'xrandr --verbose 2>/dev/null';
exec(cmd, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
result.displays = parseLinesLinuxDisplays(lines, depth);
}
if (callback) {
callback(result);
}
resolve(result);
});
if (callback) {
callback(result);
}
resolve(result);
});
});
});
}
});
// }
}
if (_freebsd || _openbsd || _netbsd) {
if (callback) { callback(null); }