Skip to content

Commit 26d757d

Browse files
author
Lionel Penaud
committed
feat(interlaced): add interlaced boolean in mode objects
1 parent 2825762 commit 26d757d

File tree

4 files changed

+59
-4
lines changed

4 files changed

+59
-4
lines changed

README.md

+51-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
11
# node-xrandr
22

3-
## Allow parsing of xrandr output
3+
An xrandr output parser
44

5+
## Usage
56

7+
```
8+
import xrandrParser from 'xrandr';
9+
10+
exec('xrandr', (err, stdout) => {
11+
console.log(xrandrParser(stdout));
12+
});
13+
```
14+
15+
## Output
16+
17+
```
18+
{
19+
"DP1": {
20+
"connected": false,
21+
"modes": []
22+
},
23+
"HDMI1": {
24+
"connected": true,
25+
"modes": [
26+
{
27+
"current": true,
28+
"native": true,
29+
"height": 1080,
30+
"rate": 60,
31+
"width": 1920
32+
},
33+
{
34+
"height": 1080,
35+
"rate": 60,
36+
"width": 1920,
37+
"interlaced": true
38+
},
39+
{
40+
"height": 1050,
41+
"rate": 60,
42+
"width": 1680
43+
}
44+
]
45+
},
46+
"HDMI2": {
47+
"connected": false,
48+
"modes": []
49+
},
50+
"VIRTUAL1": {
51+
"connected": false,
52+
"modes": []
53+
}
54+
}
55+
```

src/xrandr.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default function xrandrParser(input) {
3939
height: parseInt(parts[2], 10),
4040
rate: parseFloat(parts[3], 10)
4141
};
42+
if (/^[0-9]+i$/.test(parts[2])) mode.interlaced = true;
4243
if (parts[4] === '+' || parts[5] === '+') mode.native = true;
4344
if (parts[4] === '*' || parts[5] === '*') mode.current = true;
4445
result[lastInterface].modes.push(mode);

test/fixtures/output1.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
{
1717
"height": 1080,
1818
"rate": 60,
19-
"width": 1920
19+
"width": 1920,
20+
"interlaced": true
2021
},
2122
{
2223
"height": 1050,
@@ -76,7 +77,8 @@
7677
{
7778
"height": 576,
7879
"rate": 50,
79-
"width": 720
80+
"width": 720,
81+
"interlaced": true
8082
},
8183
{
8284
"height": 480,

test/fixtures/output3.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
{
1616
"height": 1080,
1717
"rate": 60,
18-
"width": 1920
18+
"width": 1920,
19+
"interlaced": true
1920
},
2021
{
2122
"height": 1050,
@@ -75,6 +76,7 @@
7576
},
7677
{
7778
"height": 576,
79+
"interlaced": true,
7880
"rate": 50,
7981
"width": 720
8082
},

0 commit comments

Comments
 (0)