parse w/h in mm

This commit is contained in:
Roberto Alsina 2020-02-05 19:57:47 -03:00
parent 172b943f26
commit 6ca4100bab

View File

@ -64,6 +64,8 @@ class Monitor:
primary = False primary = False
orientation = "normal" orientation = "normal"
item = None item = None
w_in_mm = 100
h_in_mm = 100
def __init__(self, data): def __init__(self, data):
"""Initialize a monitor object out of data from xrandr --verbose. """Initialize a monitor object out of data from xrandr --verbose.
@ -82,6 +84,7 @@ class Monitor:
if self.enabled: if self.enabled:
self.pos_x, self.pos_y = parse.search("+{:d}+{:d}", self.header) self.pos_x, self.pos_y = parse.search("+{:d}+{:d}", self.header)
self.res_x, self.res_y = parse.search("{:d}x{:d}", self.header) self.res_x, self.res_y = parse.search("{:d}x{:d}", self.header)
self.w_in_mm, self.h_in_mm = parse.search("{:d}mm x {:d}mm", self.header)
self.orientation = parse.search("{:w} (normal left inverted", self.header)[0] self.orientation = parse.search("{:w} (normal left inverted", self.header)[0]
modes_data = _split_by_lines_matching("^ [^ ]", data) modes_data = _split_by_lines_matching("^ [^ ]", data)