diff --git a/README.md b/README.md index 10f16d0..1590df2 100644 --- a/README.md +++ b/README.md @@ -394,6 +394,7 @@ I am happy to discuss any comments and suggestions. Please feel free to contact | Version | Date | Comment | | -------------- | -------------- | -------- | +| 3.5.1 | 2016-09-14 | bugfix graphics info | | 3.5.0 | 2016-09-14 | added graphics info (controller, display) | | 3.4.4 | 2016-09-02 | tiny fixes system.model, getDefaultNetworkInterface | | 3.4.3 | 2016-09-02 | tiny bug fix fsStats, disksIO OSX | diff --git a/lib/index.js b/lib/index.js index 536fdfe..a05e9dc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -81,6 +81,7 @@ // -------------------------------- // // version date comment +// 3.5.1 2016-09-14 bugfix graphics info // 3.5.0 2016-09-14 added graphics info (controller, display) // 3.4.4 2016-09-02 tiny fixes system.model, getDefaultNetworkInterface // 3.4.3 2016-09-02 tiny bug fix fsStats, disksIO OSX @@ -1149,7 +1150,10 @@ function graphics(callback) { } reject(error); } - let result = {}; + let result = { + controllers: [], + displays: [] + }; if (_darwin) { let cmd = 'system_profiler SPDisplaysDataType'; exec(cmd, function (error, stdout) { @@ -1169,26 +1173,26 @@ function graphics(callback) { if (!error) { let lines = stdout.toString().split('\n'); result.controllers = parseLinesLinuxControllers(lines); - let cmd = "xdpyinfo 2>/dev/null | grep 'depth of root window' | awk '{ print $5 }'"; + } + 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'); + depth = parseInt(lines[0]) || 0; + } + 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); }) - } + }) }) } });