diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-10 20:17:35 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-10 20:17:35 +0100 |
commit | 3af89b858c7d86cb23bb75a68a3643449a4b15c3 (patch) | |
tree | c6cc9f27b28fb92d8e4e34c18a88f055640a1062 /src/monitor.py | |
parent | update todo (diff) | |
download | blueshift-3af89b858c7d86cb23bb75a68a3643449a4b15c3.tar.gz blueshift-3af89b858c7d86cb23bb75a68a3643449a4b15c3.tar.bz2 blueshift-3af89b858c7d86cb23bb75a68a3643449a4b15c3.tar.xz |
add EDID support
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/monitor.py')
-rw-r--r-- | src/monitor.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/monitor.py b/src/monitor.py index 70a86e6..7e81d5a 100644 --- a/src/monitor.py +++ b/src/monitor.py @@ -267,6 +267,18 @@ class Screens: rc += screen.find_by_connected(status) return rc + def find_by_edid(self, edid): + ''' + Find output by extended display identification data + + @param edid:str? The extended display identification data of the monitor + @return :list<Output> Matching outputs + ''' + rc = [] + for screen in self.screens: + rc += screen.find_by_edid(edid) + return rc + def __contains__(self, other): return other in self.screens def __getitem__(self, index): @@ -350,6 +362,19 @@ class Screen: rc.append(self.outputs[i]) return rc + def find_by_edid(self, edid): + ''' + Find output by extended display identification data + + @param edid:str? The extended display identification data of the monitor + @return :list<Output> Matching outputs + ''' + rc = [] + for i in range(len(self.outputs)): + if self.outputs[i].edid == edid: + rc.append(self.outputs[i]) + return rc + def __repr__(self): ''' Return a string representation of the instance @@ -366,6 +391,7 @@ class Output: @variable heigthmm:int? The physical height of the monitor, measured in millimetres, `None` if unknown or not connected @variable crtc:int? The CRTC index, `None` if not connected @variable screen:int? The screen index, `None` if none + @variable edid:str? Extended display identification data, `None` if none ''' def __init__(self): ''' @@ -377,14 +403,15 @@ class Output: self.heightmm = None self.crtc = None self.screen = None + self.edid = None def __repr__(self): ''' Return a string representation of the instance ''' - rc = [self.name, self.connected, self.widthmm, self.heightmm, self.crtc, self.screen] - rc = tuple([self.name] + list(map(lambda x : repr(x), rc[1:]))) - rc = '[Name: %s, Connected: %s, Width: %s, Height: %s, CRTC: %s, Screen: %s]' % rc + rc = [self.name, self.connected, self.widthmm, self.heightmm, self.crtc, self.screen, self.edid] + rc = tuple(rc[:1] + list(map(lambda x : repr(x), rc[1 : -1])) + [str(rc[-1])]) + rc = '[Name: %s, Connected: %s, Width: %s, Height: %s, CRTC: %s, Screen: %s, EDID: %s]' % rc return rc def list_screens(): @@ -423,6 +450,8 @@ def list_screens(): output.widthmm, output.heightmm = None, None elif line.startswith('CRTC: '): output.crtc = int(line[len('CRTC: '):]) + elif line.startswith('EDID: '): + output.edid = line[len('EDID: '):] rc = Screens() rc.screens = screens return rc |