diff --git a/tests/test_monitor.py b/tests/test_monitor.py new file mode 100644 index 0000000..4fd723e --- /dev/null +++ b/tests/test_monitor.py @@ -0,0 +1,10 @@ +from xrandroll.monitor import Monitor + + +def test_parse_pos(): + data = [ + "eDP connected primary 1920x1080+0+1080 (0x56) normal (normal left inverted right x axis y axis) 309mm x 173mm" + ] + m = Monitor(data) + assert m.pos_x == 0 + assert m.pos_y == 1080 diff --git a/xrandroll/monitor.py b/xrandroll/monitor.py index b573a6e..a107b6b 100644 --- a/xrandroll/monitor.py +++ b/xrandroll/monitor.py @@ -67,7 +67,11 @@ class Monitor: self.output = parse.search("{}{:s}", self.header)[0] modes_data = _split_by_lines_matching("^ [^ ]", data) - fields_data = _split_by_lines_matching(r"^\t[^ ]", modes_data.pop(0)) + + if modes_data: + fields_data = _split_by_lines_matching(r"^\t[^ ]", modes_data.pop(0)) + else: + fields_data = [] self.modes = {} for m in (Mode(d) for d in modes_data):