File tree 4 files changed +59
-4
lines changed
4 files changed +59
-4
lines changed Original file line number Diff line number Diff line change 1
1
# node-xrandr
2
2
3
- ## Allow parsing of xrandr output
3
+ An xrandr output parser
4
4
5
+ ## Usage
5
6
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
+ ```
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export default function xrandrParser(input) {
39
39
height : parseInt ( parts [ 2 ] , 10 ) ,
40
40
rate : parseFloat ( parts [ 3 ] , 10 )
41
41
} ;
42
+ if ( / ^ [ 0 - 9 ] + i $ / . test ( parts [ 2 ] ) ) mode . interlaced = true ;
42
43
if ( parts [ 4 ] === '+' || parts [ 5 ] === '+' ) mode . native = true ;
43
44
if ( parts [ 4 ] === '*' || parts [ 5 ] === '*' ) mode . current = true ;
44
45
result [ lastInterface ] . modes . push ( mode ) ;
Original file line number Diff line number Diff line change 16
16
{
17
17
"height" : 1080 ,
18
18
"rate" : 60 ,
19
- "width" : 1920
19
+ "width" : 1920 ,
20
+ "interlaced" : true
20
21
},
21
22
{
22
23
"height" : 1050 ,
76
77
{
77
78
"height" : 576 ,
78
79
"rate" : 50 ,
79
- "width" : 720
80
+ "width" : 720 ,
81
+ "interlaced" : true
80
82
},
81
83
{
82
84
"height" : 480 ,
Original file line number Diff line number Diff line change 15
15
{
16
16
"height" : 1080 ,
17
17
"rate" : 60 ,
18
- "width" : 1920
18
+ "width" : 1920 ,
19
+ "interlaced" : true
19
20
},
20
21
{
21
22
"height" : 1050 ,
75
76
},
76
77
{
77
78
"height" : 576 ,
79
+ "interlaced" : true ,
78
80
"rate" : 50 ,
79
81
"width" : 720
80
82
},
You can’t perform that action at this time.
0 commit comments