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 ✅ ## Node.js ✅, Bun ✅ and Deno ✅
I tested this library with Node.js, Bun and Deno (V2.x) with no issues. There is I tested this library with Node.js, Bun and Deno (V2.x) with no issues. There
currently only one problem on Denos side: os.freemem() pollyfill is currently was only one problem on Denos side in version <= 2.1.4: os.freemem() pollyfill
not correct (version 2.1.4) but there is already a fix (not yet published). 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 **Attention**: This library is supposed to be used as a backend/server-side
library and **will definitely not work within a browser**. library and **will definitely not work within a browser**.

View File

@ -768,23 +768,27 @@ function graphics(callback) {
vramDynamic: true vramDynamic: true
}); });
} }
if (callback) { // if (callback) {
callback(result); // callback(result);
} // }
resolve(result); // resolve(result);
}); });
} else { }
// } else {
let cmd = 'lspci -vvv 2>/dev/null'; let cmd = 'lspci -vvv 2>/dev/null';
exec(cmd, function (error, stdout) { exec(cmd, function (error, stdout) {
if (!error) { if (!error) {
let lines = stdout.toString().split('\n'); let lines = stdout.toString().split('\n');
if (result.controllers.length === 0) {
result.controllers = parseLinesLinuxControllers(lines); result.controllers = parseLinesLinuxControllers(lines);
const nvidiaData = nvidiaDevices(); const nvidiaData = nvidiaDevices();
// needs to be rewritten ... using no spread operators // needs to be rewritten ... using no spread operators
result.controllers = result.controllers.map((controller) => { // match by busAddress result.controllers = result.controllers.map((controller) => { // match by busAddress
return mergeControllerNvidia(controller, nvidiaData.find((contr) => contr.pciBus.toLowerCase().endsWith(controller.busAddress.toLowerCase())) || {}); 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) { exec(cmd, function (error, stdout) {
if (!error) { if (!error) {
@ -812,7 +816,7 @@ function graphics(callback) {
}); });
}); });
}); });
} // }
} }
if (_freebsd || _openbsd || _netbsd) { if (_freebsd || _openbsd || _netbsd) {
if (callback) { callback(null); } if (callback) { callback(null); }