Show mode frequency

This commit is contained in:
Roberto Alsina 2022-06-08 12:46:51 -03:00
parent afc6067d2b
commit dce8545ed3
2 changed files with 4 additions and 2 deletions

View File

@ -21,7 +21,8 @@ def test_parse_modes(test_data):
m = Monitor(data) m = Monitor(data)
assert len(m.modes) == 9 assert len(m.modes) == 9
assert "0x56" in m.modes assert "0x56" in m.modes
assert str(m.modes["0x56"]) == "1920x1080 (0x56)" assert str(m.modes["0x56"]) == "1920x1080 60Hz (0x56)"
assert m.modes["0x56"].frequency == 60.01
assert m.enabled assert m.enabled
assert m.primary assert m.primary
assert m.orientation == "normal" assert m.orientation == "normal"

View File

@ -48,12 +48,13 @@ class Mode:
self.refresh = parse.search("{refresh:f}Hz", data[2])["refresh"] self.refresh = parse.search("{refresh:f}Hz", data[2])["refresh"]
self.preferred = "+preferred" in self.header self.preferred = "+preferred" in self.header
self.current = "*current" in self.header self.current = "*current" in self.header
self.frequency = parse.search("{freq:f}Hz", data[2])["freq"]
def __repr__(self): def __repr__(self):
return self.header.strip() return self.header.strip()
def __str__(self): def __str__(self):
return f"{self.res_x}x{self.res_y} ({self.name})" return f"{self.res_x}x{self.res_y} {int(self.frequency)}Hz ({self.name})"
class Monitor: class Monitor: