Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scanning on Linux #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const EdidParser = require('./edid-parser');
class EdidReader {

// Source: http://www.komeil.com/blog/fix-edid-monitor-no-signal-dvi#li-comment-845
static eisaIds = require(`${__dirname}/../data/eisa.json`);
static eisaIds = require('../data/eisa.json');
// Source: https://uefi.org/acpi_id_list
static pnpIds = require(`${__dirname}/../data/pnp.json`);
static pnpIds = require('../data/pnp.json');

constructor() {
if (!_.includes(['linux', 'darwin'], os.platform())) {
Expand Down Expand Up @@ -59,7 +59,7 @@ class EdidReader {
// Linux fetch EDID
getLinuxSystemEdids() {
// /sys/devices/pci0000\:00/0000\:00\:02.0/drm/card0/card0-HDMI-A-1/edid
return glob('/sys/devices/pci*/0000:*/drm/card*/card*/edid')
return glob('/sys/devices/pci*/0000:*/*/drm/card*/card*/edid')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For local usage I added changes you've added to fix the error, however this line causes glob to not match any files, not sure if you added it for a reason, but I removed it and only then it matched the files needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's depending on the OS ?
@leMaik on which OS did you try this ?
The ** pattern can help in this case, to cover both possibilities.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this made it work on Ubuntu for me back then so… 🤷‍♂️ Maybe …/0000:**/drm/card… would work for both of us?

.map((edidFileName) => fs.readFileAsync(edidFileName)
.then(buffer => ({filename: edidFileName, edid: buffer.toString('hex')})))
.filter(result => result.edid !== '');
Expand All @@ -77,10 +77,10 @@ class EdidReader {
// Scan host for edids
scan() {
return this.getSystemEdids()
.map(this.formatEdid)
.map(EdidReader.formatEdid)
.then((rawEdids) => {
this.monitors = _.map(rawEdids, ({filename, edid}) => {
console.log(edid);
// console.log(edid);
const edidObj = EdidReader.parse(edid);
edidObj.outputName = EdidReader.cardOutputMapper(filename);
return edidObj;
Expand Down